Closed
Description
TypeScript Version: 2.9.2 & 3.0.0-dev.20180609
Search Terms:
setter
Code
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.
class Foo {
private _x: number;
public set x(nx: number) {
this._x = nx;
}
constructor() {
this.x = 1;
}
}
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.
Related Issues: