1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add tsc type checking (#5826)

* Add tsc type checking

* Add linting on circle

* Add node-fetch types

* Use strict mode
This commit is contained in:
Tim Neutkens 2018-12-05 21:45:50 +01:00 committed by GitHub
parent 7098501547
commit dd556bf90b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 11 deletions

View file

@ -8,6 +8,7 @@ jobs:
- checkout
- run: yarn install
- run: yarn bootstrap
- run: yarn lint
- run: yarn test
publish-stable:
docker:

View file

@ -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"
@ -27,6 +28,7 @@
"standard": {
"parser": "babel-eslint",
"ignore": [
"**/*.d.ts",
"**/node_modules/**",
"examples/with-ioc/**",
"examples/with-kea/**",

View file

@ -1,10 +1,12 @@
{
"compilerOptions": {
"strict": true,
"allowJs": true,
"noEmit": true,
"module": "esnext",
"target": "ES2017",
"esModuleInterop": true,
"moduleResolution": "node",
"jsx": "react"
}
}

View file

@ -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

View file

@ -28,7 +28,8 @@
"scripts": {
"build": "taskr",
"release": "taskr release",
"prepublish": "npm run release"
"prepublish": "npm run release",
"typescript": "tsc --noEmit"
},
"taskr": {
"requires": [
@ -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",
@ -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"

View file

@ -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"
]
}
}

3
packages/next/types/index.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
declare module '@babel/plugin-transform-modules-commonjs';
declare module 'next-server/next-config';
declare module 'next-server/constants';