TypeScript Version: 2.3.2
Code
class Wrapper {
constructor() {
/** @type {boolean} */
this.isThing = false;
this.isThing = !this.isThing;
}
}
Expected behavior:
This passes.
Actual behavior:
Every once in a while:
test.js(4,5): error TS7022: 'isThing' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
It's very inconsistent whether or not this error (and other similar errors) appears. It seems like being part of a larger project makes it much more likely.
Since this bug is much easier to consistently reproduce on larger codebases, I've pushed a commit that reproduces the bug in the context I hit upon it:
https://github.com/Zarel/Pokemon-Showdown/tree/e34c77930a7eaae05a28eb68cbc392c777b8c590
If you checkout this commit and run tsc, you'll get three errors which I believe are related:
sim/dex-data.js(101,3): error TS7022: 'exists' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
sim/dex.js(87,7): error TS2322: Type 'string[]' is not assignable to type '("Pokedex" | "FormatsData" | "Learnsets" | "Movedex" | "Statuses" | "TypeChart" | "Scripts" | "It...'.
Type 'string' is not assignable to type '"Pokedex" | "FormatsData" | "Learnsets" | "Movedex" | "Statuses" | "TypeChart" | "Scripts" | "Ite...'.
sim/dex.js(1476,33): error TS2531: Object is possibly 'null'.
(All three of them disappear when I copy/paste the relevant code into a new file to try to create a simple testcase, and all three are incorrect.)
Here's a screenshot of it failing in Visual Studio Code:


TypeScript Version: 2.3.2
Code
Expected behavior:
This passes.
Actual behavior:
Every once in a while:
It's very inconsistent whether or not this error (and other similar errors) appears. It seems like being part of a larger project makes it much more likely.
Since this bug is much easier to consistently reproduce on larger codebases, I've pushed a commit that reproduces the bug in the context I hit upon it:
https://github.com/Zarel/Pokemon-Showdown/tree/e34c77930a7eaae05a28eb68cbc392c777b8c590
If you checkout this commit and run
tsc, you'll get three errors which I believe are related:(All three of them disappear when I copy/paste the relevant code into a new file to try to create a simple testcase, and all three are incorrect.)
Here's a screenshot of it failing in Visual Studio Code: