Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 63e6194

Browse files
committed
✅ (type) Add typechecking on example project
Syncs up @types modules between root and example folders
1 parent 69ee157 commit 63e6194

14 files changed

Lines changed: 112 additions & 29 deletions

File tree

example/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start",
7-
"test": "jest"
7+
"test:lint": "cd .. && yarn tslint example/src/**/*.ts{,x} && cd example",
8+
"test:unit": "jest",
9+
"test:unit:ci": "jest --runInBand",
10+
"test:type": "tsc --noEmit",
11+
"test": "yarn test:lint && yarn test:unit && yarn test:type",
12+
"test:ci": "yarn test:lint && yarn test:unit:ci && yarn test:type"
813
},
914
"dependencies": {
1015
"mobx": "^5.9.4",
@@ -19,7 +24,6 @@
1924
"@types/jest": "^24.0.11",
2025
"@types/react-native": "^0.57.42",
2126
"@types/react-test-renderer": "^16.8.1",
22-
"@types/react": "^16.8.11",
2327
"babel-jest": "^24.7.0",
2428
"babel-plugin-module-resolver": "^3.2.0",
2529
"jest": "^24.7.0",

example/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { Component } from 'react';
22
import { View } from 'react-native';
33
import { NavigationProvider } from 'react-gondola';
44

5-
interface Props {}
6-
export default class App extends Component<Props> {
5+
interface IProps {}
6+
export default class App extends Component<IProps> {
77
render() {
88
return (
99
<NavigationProvider>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { Component } from 'react';
2-
import { Platform, StyleSheet, Text, View } from 'react-native';
2+
import { StyleSheet, Text, View } from 'react-native';
33

4-
interface Props {}
5-
export class FirstName extends Component<Props> {
4+
interface IProps {}
5+
export class FirstName extends Component<IProps> {
66
render() {
77
return (
88
<View style={styles.container}>
@@ -14,9 +14,9 @@ export class FirstName extends Component<Props> {
1414

1515
const styles = StyleSheet.create({
1616
container: {
17-
flex: 1,
18-
justifyContent: 'center',
1917
alignItems: 'center',
2018
backgroundColor: '#FFAAAA',
19+
flex: 1,
20+
justifyContent: 'center',
2121
},
2222
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { Component } from 'react';
2-
import { Platform, StyleSheet, Text, View } from 'react-native';
2+
import { StyleSheet, Text, View } from 'react-native';
33

4-
interface Props {}
5-
export class LastName extends Component<Props> {
4+
interface IProps {}
5+
export class LastName extends Component<IProps> {
66
render() {
77
return (
88
<View style={styles.container}>
@@ -14,9 +14,9 @@ export class LastName extends Component<Props> {
1414

1515
const styles = StyleSheet.create({
1616
container: {
17-
flex: 1,
18-
justifyContent: 'center',
1917
alignItems: 'center',
2018
backgroundColor: '#FF9999',
19+
flex: 1,
20+
justifyContent: 'center',
2121
},
2222
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import TestRenderer from 'react-test-renderer';
3+
4+
import { FirstName } from '../FirstName';
5+
6+
describe('FirstName', () => {
7+
it('renders correctly', () => {
8+
const testRenderer = TestRenderer.create(<FirstName />);
9+
expect(testRenderer.toJSON()).toMatchSnapshot();
10+
});
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import TestRenderer from 'react-test-renderer';
3+
4+
import { LastName } from '../LastName';
5+
6+
describe('LastName', () => {
7+
it('renders correctly', () => {
8+
const testRenderer = TestRenderer.create(<LastName />);
9+
expect(testRenderer.toJSON()).toMatchSnapshot();
10+
});
11+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`FirstName renders correctly 1`] = `
4+
<View
5+
style={
6+
Object {
7+
"alignItems": "center",
8+
"backgroundColor": "#FFAAAA",
9+
"flex": 1,
10+
"justifyContent": "center",
11+
}
12+
}
13+
>
14+
<Text>
15+
FirstName
16+
</Text>
17+
</View>
18+
`;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`LastName renders correctly 1`] = `
4+
<View
5+
style={
6+
Object {
7+
"alignItems": "center",
8+
"backgroundColor": "#FF9999",
9+
"flex": 1,
10+
"justifyContent": "center",
11+
}
12+
}
13+
>
14+
<Text>
15+
LastName
16+
</Text>
17+
</View>
18+
`;

example/src/canals/SignIn/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FirstName } from './FirstName';
22
import { LastName } from './LastName';
33

4+
// @ts-ignore
45
export const SignIn = canal(FirstName, LastName);

example/tsconfig.json

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
{
22
"compilerOptions": {
3-
"allowJs": true,
3+
"target": "esnext",
44
"allowSyntheticDefaultImports": true,
5-
"esModuleInterop": true,
6-
"isolatedModules": true,
5+
"outDir": "dist",
6+
"module": "commonjs",
77
"jsx": "react",
8-
"lib": ["es6"],
9-
"moduleResolution": "node",
10-
"noEmit": true,
118
"strict": true,
12-
"target": "esnext",
9+
"noImplicitAny": true,
10+
"strictNullChecks": true,
11+
"strictFunctionTypes": true,
12+
"strictBindCallApply": true,
13+
"strictPropertyInitialization": true,
14+
"noImplicitThis": true,
15+
"alwaysStrict": true,
16+
"noUnusedLocals": true,
17+
"noUnusedParameters": true,
18+
"noImplicitReturns": true,
19+
"noFallthroughCasesInSwitch": true,
1320
"baseUrl": "./src",
21+
"esModuleInterop": true,
22+
"experimentalDecorators": true,
23+
"emitDecoratorMetadata": true,
24+
"noEmit": true,
25+
"allowJs": true,
26+
"lib": ["es6"],
27+
"types": ["react-native"],
28+
"isolatedModules": true,
29+
"moduleResolution": "node",
1430
"paths": {
1531
"react-gondola": ["../../src"]
1632
}
1733
},
34+
"include": ["./src"],
1835
"exclude": [
36+
"../node_modules",
1937
"node_modules",
2038
"babel.config.js",
2139
"metro.config.js",
22-
"jest.config.js"
40+
"jest.config.js",
41+
"**/__tests__/*"
2342
]
2443
}

0 commit comments

Comments
 (0)