Open
Description
Keywords: JSDoc, Salsa, JavaScript, definite, initialization, initialized, assigned, assertion
class ElementWrapper {
constructor() {
this.init();
}
init() {
this.element = document.createElement('div');
}
getElementStyle() {
this.element.style // error: element is possibly undefined
}
}
We need a way to convince TypeScript in strictNullChecks
that this.element
is initialized in getElementStyle
. Basically a definite initialization assertion.
Related is #23405 which tracks non-null assertions on the expression level.