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
declareconsttextMap: {[key: string]: string}functiongetText(input: string){const{[input]: rawText=input}=textMap// rawText inferred as 'any' and not 'string'}
Expected behavior: rawText to be inferred as string
Actual behavior: rawText inferred as any
As this is a destructuring pattern, it is actually not possible at all to declare the type of rawText other than by making rawText a let declaration first and running an destructuring expression, or otherwise writing equivalent code that does not use destructuring.
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.
TypeScript Version: 2.4.0
Code
Expected behavior:
rawText
to be inferred asstring
Actual behavior:
rawText
inferred asany
As this is a destructuring pattern, it is actually not possible at all to declare the type of
rawText
other than by makingrawText
alet
declaration first and running an destructuring expression, or otherwise writing equivalent code that does not use destructuring.The text was updated successfully, but these errors were encountered: