Closed ghost closed 6 years ago
I dropped TS back to 2.6.1 and this went away.
Same as in the other issue: I'd like to fix this.
What info do you need? I'm also seeing this.
@retorquere First I'd like to know if this happens during editing when the code likely has syntax errors or if it also occurs when linting valid code. We'll try to fix it in both cases, but the latter could be a bug in TypeScript, too.
Then I need a code snippet to reproduce. To narrow it down to the file that causes the exception, you could edit lib/linter.js
. Inside the catch clause of the try-catch in applyRule, you can simply console.log(sourceFile.fileName)
.
I'm not using it inside an editor (vim user here), only during my build.
OK, I have the filenames, assuming the filename displays above the error (for my reference: content/BetterBibTeX.ts, content/keymanager.ts, content/cayw/formatter.ts, resource/Better BibTeX.ts, webpack/scripts/release.ts, setup/preferences.ts)
Ah and yes, valid code, as it compiles cleanly after. I no see they don't all display the same error, but they do look similar to me:
/home/ubuntu/zotero-better-bibtex/content/BetterBibTeX.ts
TypeError: Cannot read property 'kind' of undefined
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:69:26)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12923:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12921:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
/home/ubuntu/zotero-better-bibtex/content/Preferences.ts
/home/ubuntu/zotero-better-bibtex/content/auto-export.ts
/home/ubuntu/zotero-better-bibtex/content/dateparser.ts
/home/ubuntu/zotero-better-bibtex/content/keymanager.ts
/home/ubuntu/zotero-better-bibtex/content/keymanager.ts
TypeError: Cannot read property 'uses' of undefined
at visitForStatement (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:66:59)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:53:13)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12889:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
/home/ubuntu/zotero-better-bibtex/content/qr-check.ts
/home/ubuntu/zotero-better-bibtex/content/serializer.ts
/home/ubuntu/zotero-better-bibtex/content/cayw/formatter.ts
TypeError: Cannot read property 'uses' of undefined
at visitForStatement (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:66:59)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:53:13)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12782:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12950:21)
/home/ubuntu/zotero-better-bibtex/content/keymanager/formatter.ts
/home/ubuntu/zotero-better-bibtex/content/test/support.ts
/home/ubuntu/zotero-better-bibtex/resource/Better BibLaTeX.ts
/home/ubuntu/zotero-better-bibtex/resource/Better BibLaTeX.ts
/home/ubuntu/zotero-better-bibtex/resource/Better BibTeX.ts
/home/ubuntu/zotero-better-bibtex/resource/Better BibTeX.ts
TypeError: Cannot read property 'uses' of undefined
at visitForStatement (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:66:59)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:53:13)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12910:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
/home/ubuntu/zotero-better-bibtex/resource/Better CSL YAML.ts
/home/ubuntu/zotero-better-bibtex/resource/bibtex/reference.ts
/home/ubuntu/zotero-better-bibtex/resource/bibtex/unicode_translator.ts
/home/ubuntu/zotero-better-bibtex/resource/csl/csl.ts
/home/ubuntu/zotero-better-bibtex/resource/lib/markupparser.ts
/home/ubuntu/zotero-better-bibtex/resource/lib/markupparser.ts
/home/ubuntu/zotero-better-bibtex/webpack/loaders/wrap.ts
/home/ubuntu/zotero-better-bibtex/webpack/scripts/release.ts
TypeError: Cannot read property 'uses' of undefined
at visitForStatement (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:66:59)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:53:13)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12890:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/preferForOfRule.js:55:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12875:24)
/home/ubuntu/zotero-better-bibtex/setup/preferences.ts
TypeError: Cannot read property 'kind' of undefined
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:69:26)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12923:24)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
at visitNode (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12690:24)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12921:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
at visitNodes (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12699:30)
at Object.forEachChild (/home/ubuntu/zotero-better-bibtex/node_modules/typescript/lib/typescript.js:12926:21)
at cb (/home/ubuntu/zotero-better-bibtex/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js:81:19)
/home/ubuntu/zotero-better-bibtex/setup/translator-typing.ts
/home/ubuntu/zotero-better-bibtex/setup/loaders/bcf.ts
/home/ubuntu/zotero-better-bibtex/content/keymanager/formatter.ts
Can you share one of the failing files? Otherwise you could try to remove a big chunk of code and see if the error still occurs. Ideally I only need the offending for-loop or object literal if you can narrow it down so far.
All live at https://github.com/retorquere/zotero-better-bibtex
If I comment out https://github.com/retorquere/zotero-better-bibtex/blob/master/webpack/scripts/release.ts#L137 - https://github.com/retorquere/zotero-better-bibtex/blob/master/webpack/scripts/release.ts#L141, the error in /webpack/scripts/release.ts
("TypeError: Cannot read property 'uses' of undefined") goes away.
The other error ("Cannot read property 'kind' of undefined") comes from https://github.com/retorquere/zotero-better-bibtex/blob/master/setup/preferences.ts#L252, and there I only have to comment out the last line to make the error go away.
The other scripts are bigger so harder to bisect -- I hope these two are sufficient to figure out what's going on.
(tsconfig and tslint also in that repo, should that matter)
@retorquere I cloned your repo, installed all dependencies with yarn and ran yarn lint
.
I don't see any of the errors.
TSLint 5.8.0, TypeScript 2.6.2, macOS
I even tried to lint with the latest changes from the master branch of TSLint.
I can only reproduce the error on CircleCI (but there I can reproduce it reliably). On CircleCI, I have typescript 2.6.2, typescript 2.4.1 pulled in by typedoc 0.9.0, and tslint 5.8.0. The build runs in Ubuntu 14.04.4 LTS.
@retorquere CircleCI still uses yarn@1.1.0 which caused a lot of trouble due to strangely installed dependencies: see #3251 (and a lot of duplicates) Since we both cannot reproduce the issue locally, this is likely to be the cause.
@KSuttle-cng can you still reproduce the issue when using yarn@^1.2.1 to install your dependencies?
How do I upgrade yarn? Doing npm upgrade -g yarn
and mpm install -g yarn
didn't raise the version above 1.1.0.
What influence does yarn have here BTW? I thought yarn was just a package installer? Should I revert to npm
?
What influence does yarn have here BTW? I thought yarn was just a package installer? Should I revert to npm?
If the installer screws up, the installee (is that a word?) is not guaranteed to function correctly.
If you run yarn list
in your CI environment, you probably see that tsutils
has a different version of typescript installed than tslint
. That shouldn't have happened according to the dependencies of the packages. This bug was introduced somewhere in yarn 1.0.x and fixed in 1.2.x
Here you go @ajafff:
@ajafff upgrading yarn on circleci made the problem go away.
I'm going to close this as the problem seems to be rooted in the package installer and Yarn released a patch. Feel free to re-open if you think it's important.
Bug Report
ng lint --format=stylish
Seems to fail at this line: https://github.com/palantir/tslint/blob/master/src/rules/preferForOfRule.ts#L66 though what I just linked to, and what appears when I click the file in my terminal are not the same.
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
Expected behavior
No errors.