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
typeDastructure={b: false,c: null}|{b: true,c: string}classExample{prop?: string;constructor({b, c}: Dastructure){if(b){this.prop=c// ^^^^^^^^^// Type 'string | null' is not assignable to type 'string | undefined'.// Type 'null' is not assignable to type 'string | undefined'.}}}
🙁 Actual behavior
error
🙂 Expected behavior
not error?
I think it's because in the second code the context of {b, c}: A isn't considered when b is narrowed
The text was updated successfully, but these errors were encountered:
icecream17
changed the title
Object destructuring for parameters don't narrow
Object destructuring type doesn't narrow parameter B when parameter A is narrowed
May 19, 2021
Bug Report
🔎 Search Terms
destructuring
narrowing
is not assignable to type
🕗 Version & Regression Information
(todo)
💻 Code
This works
This gets an error
🙁 Actual behavior
error
🙂 Expected behavior
not error?
I think it's because in the second code the context of
{b, c}: A
isn't considered whenb
is narrowedThe text was updated successfully, but these errors were encountered: