Merge pull request #8 from horacioh/feature/typescript

Fix test --coverage errors related to TS
This commit is contained in:
Brent Vatne
2018-10-25 13:44:28 -07:00
parent 3147be7f36
commit 546ae506a8
15 changed files with 329 additions and 1287 deletions

View File

@@ -1,3 +1,4 @@
node_modules/
dist/
jest-setup.js
coverage/

View File

@@ -7,7 +7,6 @@
# VSCode
.vscode/
tsconfig.json
jsconfig.json
# Xcode
@@ -51,3 +50,6 @@ android/keystores/debug.keystore
# Build
dist/
# Code coverage files
coverage/

View File

@@ -11,10 +11,13 @@
],
"react-native": "src/index.js",
"scripts": {
"pretest": "yarn lint && yarn build",
"test": "jest",
"lint": "eslint .",
"format": "eslint . --fix",
"build": "babel --no-babelrc --plugins=transform-es2015-block-scoping,transform-es2015-modules-commonjs,transform-react-jsx,transform-class-properties,transform-object-rest-spread,transform-flow-strip-types src --copy-files --out-dir dist --ignore '**/__tests__/**'",
"babel": "babel --no-babelrc --plugins=transform-es2015-block-scoping,transform-es2015-modules-commonjs,transform-react-jsx,transform-class-properties,transform-object-rest-spread,transform-flow-strip-types src --copy-files --out-dir dist --ignore '**/__tests__/**'",
"tsc": "tsc",
"build": "yarn babel && yarn tsc",
"prepare": "yarn build",
"release": "release-it"
},
@@ -59,7 +62,7 @@
"eslint": "^4.12.1",
"eslint-config-satya164": "^1.0.1",
"eslint-plugin-react-native-globals": "^0.1.0",
"husky": "^0.14.3",
"husky": "^1.1.2",
"jest": "^22.1.3",
"jest-expo": "^30.0.0",
"prettier": "^1.8.2",
@@ -67,26 +70,41 @@
"react-dom": "16.3.1",
"react-native": "^0.55.4",
"react-test-renderer": "16.3.1",
"release-it": "^7.6.1"
"release-it": "^7.6.1",
"ts-jest": "^23.10.4",
"typescript": "^3.1.3"
},
"peerDependencies": {
"react": "*"
},
"jest": {
"preset": "react-native",
"testRegex": "/__tests__/[^/]+-test\\.js$",
"testRegex": "/__tests__/[^/]+-test\\.(js|tsx)?$",
"setupFiles": [
"<rootDir>/jest-setup.js"
],
"coveragePathIgnorePatterns": [
"jest-setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element)"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"modulePathIgnorePatterns": [
"<rootDir>/example/"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element)"
]
"globals": {
"ts-jest": {
"tsConfig": "./tsconfig.test.json",
"diagnostics": {
"ignoreCodes": [
151001
]
}
}
}
},
"prettier": {
"trailingComma": "es5",

View File

@@ -1,5 +1,5 @@
import getChildEventSubscriber from './getChildEventSubscriber';
import getChildRouter from './getChildRouter';
import getChildRouter from './getChildRouter.ts';
import getNavigationActionCreators from './routers/getNavigationActionCreators';
import getChildrenNavigationCache from './getChildrenNavigationCache';

View File

@@ -1,4 +1,4 @@
export default function getChildRouter(router, routeName) {
export default function getChildRouter(router: any, routeName: string) {
if (router.childRouters && router.childRouters[routeName]) {
return router.childRouters[routeName];
}

View File

@@ -1,11 +0,0 @@
let uniqueBaseId = `id-${Date.now()}`;
let uuidCount = 0;
export function _TESTING_ONLY_normalize_keys() {
uniqueBaseId = 'id';
uuidCount = 0;
}
export function generateKey() {
return `${uniqueBaseId}-${uuidCount++}`;
}

View File

@@ -0,0 +1,11 @@
let uniqueBaseId: string = `id-${Date.now()}`;
let uuidCount: number = 0;
export function _TESTING_ONLY_normalize_keys(): void {
uniqueBaseId = 'id';
uuidCount = 0;
}
export function generateKey(): string {
return `${uniqueBaseId}-${uuidCount++}`;
}

View File

@@ -5,7 +5,7 @@ import getScreenForRouteName from './getScreenForRouteName';
import StateUtils from '../StateUtils';
import validateRouteConfigMap from './validateRouteConfigMap';
import invariant from '../utils/invariant';
import { generateKey } from './KeyGenerator';
import { generateKey } from './KeyGenerator.ts';
import { createPathParser } from './pathUtils';
function behavesLikePushAction(action) {

View File

@@ -6,7 +6,7 @@ import SwitchRouter from '../SwitchRouter';
import StackRouter from '../StackRouter';
import TabRouter from '../TabRouter';
import NavigationActions from '../../NavigationActions';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator.ts';
beforeEach(() => {
_TESTING_ONLY_normalize_keys();

View File

@@ -7,7 +7,7 @@ import TabRouter from '../TabRouter';
import SwitchRouter from '../SwitchRouter';
import NavigationActions from '../../NavigationActions';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator.ts';
beforeEach(() => {
_TESTING_ONLY_normalize_keys();

View File

@@ -5,7 +5,7 @@ import React from 'react';
import StackRouter from '../StackRouter';
import StackActions from '../StackActions';
import NavigationActions from '../../NavigationActions';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator';
import { _TESTING_ONLY_normalize_keys } from '../KeyGenerator.ts';
beforeEach(() => {
_TESTING_ONLY_normalize_keys();

View File

@@ -0,0 +1,31 @@
{
"compilerOptions": {
"module": "es2015",
"target": "esnext",
"lib": ["dom", "es2015", "es2016"],
"sourceMap": false,
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"declaration": true,
"pretty": true,
"jsx": "react-native",
"noEmitHelpers": true,
"importHelpers": true,
"strict": true,
"outDir": "dist",
"declarationDir": "./types",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"typeAcquisition": {
"enable": true,
"include": ["prop-types", "react", "react-native"]
}
}

View File

@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"sourceMap": true
}
}

15
packages/core/tslint.json Normal file
View File

@@ -0,0 +1,15 @@
{
"extends": "tslint:recommended",
"rules": {
"arrow-parens": [true, "ban-single-arg-parens"],
"arrow-return-shorthand": [true, "multiline"],
"trailing-comma": false,
"quotemark": {
"options": [
"single",
"avoid-escape"
]
},
"object-literal-sort-keys": false
}
}

File diff suppressed because it is too large Load Diff