You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When enabling the strictNullChecks and strictPropertyInitialization tsconfig options tsc produces an error when it shouldn't. It looks like the rule implementation of the aforementioned strict flags might not account for setters? Easily verifiable in the typescript repl too, once enabling the flags.
TypeScript Version: 2.9.2 & 3.0.0-dev.20180609
Search Terms:
setter
Code
When enabling the
strictNullChecks
andstrictPropertyInitialization
tsconfig options tsc produces an error when it shouldn't. It looks like the rule implementation of the aforementioned strict flags might not account for setters? Easily verifiable in the typescript repl too, once enabling the flags.tsc:
Property '_x' has no initializer and is not definitely assigned in the constructor.
Expected behavior:
No errors.
Actual behavior:
tsc emits
Property '_x' has no initializer and is not definitely assigned in the constructor.
error.Playground Link:
http://www.typescriptlang.org/play/#src=class%20Foo%20%7B%0D%0A%20%20%20%20private%20_x%3A%20number%3B%0D%0A%20%20%20%20public%20set%20x(nx%3A%20number)%20%7B%0D%0A%20%20%20%20%20%20%20%20this._x%20%3D%20nx%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20constructor()%20%7B%0D%0A%20%20%20%20%20%20%20%20this.x%20%3D%201%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A
Related Issues:
The text was updated successfully, but these errors were encountered: