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
constthrowParseError=(def: unknown): never=>{thrownewError(`${def} is not a valid definition`)}classFoo{// Property 'bar' has no initializer and is not definitely assigned in the constructor.(2564)bar: stringconstructor(def: string|null){if(def===null){// this return pattern is useful for narrowing// if you remove `return` here, the initialization error goes away// but the assignment to bar is then an errorreturnthrowParseError(null)}this.bar=def}}
π Actual behavior
TypeScript reports that Property 'bar' has no initializer and is not definitely assigned in the constructor.(2564)
π Expected behavior
TypeScript should identify that in every viable branch of the constructor, bar is assigned.