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
TypeScript does not understand that the type of a variable has changed following a type narrowing.
The type of a variable is announced as the type with which the variable has been declared - even if its type has been refined since via type narrowing.
π» Use Cases
What workarounds are you using in the meantime?
Creating a copy of the variable. TypeScript understands the type of the new variable.
The text was updated successfully, but these errors were encountered:
π Search Terms
narrowing, type, variable, redefinition
β Viability Checklist
β Suggestion
TypeScript should understand that the type of a variable has changed, following a type narrowing:
Playground link:
https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVzAQygGdgAVCMTNASQBMAKNYAG2YDV9mlgAuOVANYoIAdxQBKPiiQBbAEbAocAN4AoAJDNg8GBSp04AXjhNWHLsADcqjQHpbJ-ER0Q4zqJhQBzOJgR4IIiJMOS0NPzh6GABPMGAIf11KGlojQ2MAIml5RQzxFQ11JP1U42KUgDpdAGUYD296cWt1AF8bdQio2PjEvRS4AEJ0uAz3Ty88gvUigAsoUTgUYBE4AFEoeah6DOoUADdOTFTy31o85raNcoMyvroKojBmTBhtiryAbQAGAF1m69KcAAcrIFFAKgRiMBdq8AU12p0QTlwZgiED8ECondaOJ8mppjA5gslit1pt6AADXYHZ7HPqnEYAEmUAJaGQp8Na7Sg2iQUFwAOsbSAA
π Motivating Example
TypeScript does not understand that the type of a variable has changed following a type narrowing.
The type of a variable is announced as the type with which the variable has been declared - even if its type has been refined since via type narrowing.
π» Use Cases
What workarounds are you using in the meantime?
Creating a copy of the variable. TypeScript understands the type of the new variable.
The text was updated successfully, but these errors were encountered: