Fork-ts-checker-webpack-plugin: skipLibCheck: true in tsconfig.json causes unexplainable tslint errors

Created on 2 Aug 2018  路  9Comments  路  Source: TypeStrong/fork-ts-checker-webpack-plugin

Versions:

"ts-loader": "^4.4.2",
"tslint": "^5.11.0",
"tslint-loader": "^3.6.0",
"tslint-react": "^3.2.0",
"typescript": "~2.9.2",
"fork-ts-checker-webpack-plugin": "^0.4.3",
"webpack": "^4.16.3"

When I enable skipLibCheck, I get these seemingly random TypeErrors on build:
The 'variable-name' rule threw an error in '/Users/cameron/Code/refresh-react/packages/client/src/Config/Monitor/MonitorReducer.ts': TypeError: Cannot read property 'kind' of undefined at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/variableNameRule.js:95:37) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14972:24) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/variableNameRule.js:120:19) at visitNode (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14800:24) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14862:21) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/variableNameRule.js:120:19) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14925:21) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/variableNameRule.js:120:19) The 'whitespace' rule threw an error in '/Users/cameron/Code/refresh-react/packages/client/src/Config/Monitor/MonitorReducer.ts': TypeError: Cannot read property 'text' of undefined at Object.getTokenPosOfNode (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:8984:72) at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:106812:23) at /Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/whitespaceRule.js:146:69 at Array.forEach (<anonymous>) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/whitespaceRule.js:138:54) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:15035:24) at walk (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/whitespaceRule.js:88:8) at Rule.AbstractRule.applyWithFunction (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/language/rule/abstractRule.js:39:9) at Rule.apply (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/whitespaceRule.js:40:21) The 'no-shadowed-variable' rule threw an error in '/Users/cameron/Code/refresh-react/packages/client/src/Config/Monitor/MonitorContainer.ts': TypeError: Cannot read property 'kind' of undefined at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/noShadowedVariableRule.js:191:37) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14925:21) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/noShadowedVariableRule.js:223:20) at visitNode (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14800:24) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14893:21) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/noShadowedVariableRule.js:228:27) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:15042:24) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/noShadowedVariableRule.js:228:27) The 'quotemark' rule threw an error in '/Users/cameron/Code/refresh-react/packages/client/src/Config/Monitor/MonitorContainer.ts': TypeError: Cannot read property 'kind' of undefined at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/quotemarkRule.js:83:49) at visitNode (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14800:24) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:15144:21) at cb (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/quotemarkRule.js:109:12) at visitNodes (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:14809:30) at Object.forEachChild (/Users/cameron/Code/refresh-react/packages/client/node_modules/typescript/lib/typescript.js:15035:24) at walk (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/quotemarkRule.js:78:8) at Rule.AbstractRule.applyWithFunction (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/language/rule/abstractRule.js:39:9) at Rule.apply (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/rules/quotemarkRule.js:41:21) at Linter.applyRule (/Users/cameron/Code/refresh-react/packages/client/node_modules/tslint/lib/linter.js:197:29)

There isn't anything wrong with these files, and the errors and files change when I change different bits of code. I don't get this issue if I do not enable tslint in the plugin options and use tslint-loader directly. Any ideas? :(

Most helpful comment

I'm having this problem as well. The only way to prevent it is to remove skipLibCheck: true from tsconfig.json.

All 9 comments

I've never seen that and I'm using ts-lint. Is it linked to your tslint.json in any way perhaps? If you tweak it does the problem disappear?

I'm having this problem as well. The only way to prevent it is to remove skipLibCheck: true from tsconfig.json.

Same issue for me. Both with TypeScript 2.9.2 and 3.1.6. Both with tslint 5.11.0 and 5.5.0. There are no such messages with tslint 5.4.3, but this is probably due to https://github.com/palantir/tslint/pull/2890 that went to 5.5.0, so, in fact, the errors may still be there in the older versions. Disabling skipLibCheck solves the issue, but makes the build somewhat slower, so I'd prefer fork-ts-checker to work with both settings for this option.
This doesn't seem to be tslint's issue since running ./node_modules/.bin/tslint -c tslint.json -p . doesn't print any errors with skipLibCheck: true.
I've debugged this a bit and for some reason node or token variable sometimes doesn't have parent property when tslint is run via fork-ts-checker, but it does have it when tslint is run from console.

Could you provide a minimal repro please? We still don't know what's actually causing this. I personally haven't seen this at all despite using skipLibCheck: true

Please see https://github.com/ddrozdov/fork-ts-checker-tslint-errors-135-repro

$ npm run start
...
The 'no-unnecessary-initializer' rule threw an error in '/tmp/fork-ts-checker-tslint-errors-135-repro/src/index.ts':
TypeError: Cannot read property 'flags' of undefined
    at Object.isFlagSet (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/tsutils/util/util.js:72:17)
    at cb (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js:57:74)
    at visitNodes (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:15788:30)
    at Object.forEachChild (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:16023:24)
    at cb (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js:78:12)
    at visitNode (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:15779:24)
    at Object.forEachChild (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:16021:21)
    at cb (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js:78:12)
    at visitNodes (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:15788:30)
    at Object.forEachChild (/tmp/fork-ts-checker-tslint-errors-135-repro/node_modules/typescript/lib/typescript.js:16016:24)
No type errors found
No lint errors found
Version: typescript 3.1.6, tslint 5.11.0

There are no issues with workers: 1 - so this may be considered as a workaround.
There are no issues without @types/history dependency.

I have upgraded the typescript version from v2.9.2 to v3.3.3333 and the issue is been resolved.

I get this problem when I upgrade TypeScript to 3.2+. 3.1 is fine.

It seems to be a bug from TSC per se. Ref: https://github.com/Microsoft/TypeScript/issues/28810

/home/my-secret-path/node_modules/fork-ts-checker-webpack-plugin/lib/service.js:22
[]         throw error;
[]         ^
[]
[] TypeError: Cannot read property 'kind' of undefined
[]     at checkNestedBlockScopedBinding (/home/my-secret-path/node_modules/typescript/lib/typescript.js:45885:48)
[]     at checkIdentifier (/home/my-secret-path/node_modules/typescript/lib/typescript.js:45791:13)
[]     at checkExpressionWorker (/home/my-secret-path/node_modules/typescript/lib/typescript.js:51773:28)
[]     at checkExpression (/home/my-secret-path/node_modules/typescript/lib/typescript.js:51745:42)
[]     at checkNonNullExpression (/home/my-secret-path/node_modules/typescript/lib/typescript.js:48096:37)
[]     at checkPropertyAccessExpressionOrQualifiedName (/home/my-secret-path/node_modules/typescript/lib/typescript.js:48129:28)
[]     at checkPropertyAccessExpression (/home/my-secret-path/node_modules/typescript/lib/typescript.js:48122:20)
[]     at checkExpressionWorker (/home/my-secret-path/node_modules/typescript/lib/typescript.js:51802:28)
[]     at checkExpression (/home/my-secret-path/node_modules/typescript/lib/typescript.js:51745:42)
[]     at checkNonNullExpression (/home/my-secret-path/node_modules/typescript/lib/typescript.js:48096:37)

It looks like this bug is not directly related to the fork-ts-checker-webpack-plugin :)

Was this page helpful?
0 / 5 - 0 ratings