Skip to content

Commit

Permalink
Add tsc type checking (vercel#5826)
Browse files Browse the repository at this point in the history
* Add tsc type checking

* Add linting on circle

* Add node-fetch types

* Use strict mode
  • Loading branch information
timneutkens authored Dec 5, 2018
1 parent 7098501 commit dd556bf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
- checkout
- run: yarn install
- run: yarn bootstrap
- run: yarn lint
- run: yarn test
publish-stable:
docker:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"pretest": "npm run lint",
"test": "npm run testall || npm run testall",
"coveralls": "cat ./test/coverage/lcov.info | coveralls",
"lint": "standard && standard --parser typescript-eslint-parser --plugin typescript packages/**/*.ts",
"lint": "lerna run typescript && standard && standard --parser typescript-eslint-parser --plugin typescript packages/**/*.ts",
"typescript": "lerna run typescript",
"prepublish": "lerna run prepublish",
"publish-canary": "lerna version prerelease --preid canary --force-publish",
"lint-staged": "lint-staged"
Expand All @@ -27,6 +28,7 @@
"standard": {
"parser": "babel-eslint",
"ignore": [
"**/*.d.ts",
"**/node_modules/**",
"examples/with-ioc/**",
"examples/with-kea/**",
Expand Down
2 changes: 2 additions & 0 deletions packages/next-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"compilerOptions": {
"strict": true,
"allowJs": true,
"noEmit": true,
"module": "esnext",
"target": "ES2017",
"esModuleInterop": true,
"moduleResolution": "node",
"jsx": "react"
}
}
8 changes: 5 additions & 3 deletions packages/next/build/babel/plugins/react-loadable-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export default function ({ types: t }: {types: typeof BabelTypes}): PluginObj {

if (
callExpression.isMemberExpression() &&
callExpression.node.computed === false &&
callExpression.get('property').isIdentifier({ name: 'Map' })
callExpression.node.computed === false
) {
callExpression = callExpression.parentPath
const property = callExpression.get('property')
if (!Array.isArray(property) && property.isIdentifier({ name: 'Map' })) {
callExpression = callExpression.parentPath
}
}

if (!callExpression.isCallExpression()) return
Expand Down
5 changes: 4 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"scripts": {
"build": "taskr",
"release": "taskr release",
"prepublish": "npm run release"
"prepublish": "npm run release",
"typescript": "tsc --noEmit"
},
"taskr": {
"requires": [
Expand Down Expand Up @@ -91,6 +92,7 @@
"react-dom": "^16.0.0"
},
"devDependencies": {
"@babel/parser": "7.2.0",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand All @@ -100,6 +102,7 @@
"@types/babel__template": "7.0.1",
"@types/babel__traverse": "7.0.3",
"@types/nanoid": "1.2.0",
"@types/node-fetch": "2.1.4",
"@types/webpack": "4.4.20",
"taskr": "1.1.0",
"typescript": "3.1.6"
Expand Down
9 changes: 3 additions & 6 deletions packages/next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"compilerOptions": {
"strict": true,
"allowJs": true,
"noEmit": true,
"module": "esnext",
"target": "ES2017",
"esModuleInterop": true,
"moduleResolution": "node",
"jsx": "react",
"strictNullChecks": true,
"noImplicitAny": true,
"baseUrl": "../..",
"paths": {
"@babel/types": [
"babel-types/index.d.ts",
"@types/babel-types/index.d.ts",
"node_modules/@types/babel-types/index.d.ts",
"packages/next/node_modules/@types/babel-types/index.d.ts"
"@types/babel-types/index.d.ts"
]
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/next/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '@babel/plugin-transform-modules-commonjs';
declare module 'next-server/next-config';
declare module 'next-server/constants';

0 comments on commit dd556bf

Please sign in to comment.