We have enabled strictNullChecks, but the TS compiler doesn't catch the following:
class A {
prop: number;
constructor() {
// forgot to assign to prop, so it will be undefined...
}
}
Possible fixes:
class A {
prop: number;
constructor() {
this.prop = 5; // Assign the property in the ctor
}
}
class A {
prop!: number; // use exclamation mark to suppress the error
constructor() {
this._init();
}
private _init() {
this.prop = 5;
}
}
In order to get errors for such cases, we need to add "strictPropertyInitialization": true to our tsconfig.json.
@microsoft/vscode it would be nice if we could tackle some of these errors during debt week.
[edit 11.11]: There are 8 errors left:
We have enabled
strictNullChecks, but the TS compiler doesn't catch the following:Possible fixes:
In order to get errors for such cases, we need to add
"strictPropertyInitialization": trueto ourtsconfig.json.@microsoft/vscode it would be nice if we could tackle some of these errors during debt week.
[edit 11.11]: There are 8 errors left:
vs/base/browser/ui/tree/asyncDataTree.ts@joaomorenosrc/vs/workbench/api/common/extHostTypes.ts@jriekensrc/vs/workbench/api/common/extHostWebview.ts@mjbvz