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
If I use variable which has type set via type guard in nested anonymous class - it becomes of type any. TypeScript Version: 3.8.3
Search Terms: Type guard, type propagation
Code
functionisError(error: Error|any): error is Error{returnerrorinstanceofError;}try{thrownewError('test');}catch(hookError){if(isError(hookError)){consterrorHandler=classextendsError{log(){// hookError is anyconsole.log(hookError.message);}};}else{throwhookError;}}
Expected behavior: hookError in console.log should have type Error
If I use variable which has type set via type guard in nested anonymous class - it becomes of type any.
TypeScript Version: 3.8.3
Search Terms: Type guard, type propagation
Code
Expected behavior: hookError in console.log should have type Error
Actual behavior: hookError has type any
Playground Link: http://www.typescriptlang.org/play/?ssl=21&ssc=1&pln=1&pc=1#code/GYVwdgxgLglg9mABDAzgUQE4bhgFAUyxwC5FNsNEAfRAQzAE8BKUwi5FMoygbwChEiDPiggMSNjmRgUUehHxxgXCgG4+AXz58oGBon6DBUABbYA7ojD5L5HLgDkUfLIdN1GxBFpQIJ3CZwcADWdhhMBgJGMMC4qGEBQaHcTBGGRlFGRhAIsoiSGAAS9AAmADaEiAC8XmW0KJz4AB7OYCWcYZFZmVm9ZXAA5rhpPb1jiAD0E4iBIZ2odIyj41k5MnAVAHT9Q7PJFJsAti4otAP47stjWisa6lme+GUo+F3jphYzSWH3RlpaQA
Related Issues: I think this #30557 could be same issue, but not sure
The text was updated successfully, but these errors were encountered: