Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipLibCheck: true in tsconfig.json causes unexplainable tslint errors #135

Closed
khell opened this issue Aug 2, 2018 · 9 comments
Closed

Comments

@khell
Copy link

khell commented Aug 2, 2018

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:

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? :(

@johnnyreilly
Copy link
Member

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?

@ChadBurggraf
Copy link

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

@ddrozdov
Copy link

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 palantir/tslint#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.

@johnnyreilly
Copy link
Member

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

ddrozdov added a commit to ddrozdov/fork-ts-checker-tslint-errors-135-repro that referenced this issue Nov 15, 2018
@ddrozdov
Copy link

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.

@121371
Copy link

121371 commented Feb 25, 2019

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

@yuqingc
Copy link

yuqingc commented Mar 5, 2019

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

@yuqingc
Copy link

yuqingc commented Mar 5, 2019

It seems to be a bug from TSC per se. Ref: microsoft/TypeScript#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)

@piotr-oles
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants