Fix: checkAliasSymbol crash when checking for @deprecated#42971
Fix: checkAliasSymbol crash when checking for @deprecated#42971
Conversation
It's possible that we shouldn't be creating symbol with no declarations from non-homomorphic mapped types, but for 4.2, the right fix is to make the @deprecated-check in checkAliasSymbol ensure that target.declarations is defined.
|
@RyanCavanaugh @DanielRosenwasser you are probably interested in this too. |
|
We've been creating symbols this way since at least 3.0. The right thing to do is to put |
| error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); | ||
| } | ||
|
|
||
| if (isImportSpecifier(node) && every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) { |
There was a problem hiding this comment.
Our every helper doesn't handle undefined? Most of our other array helpers treat undefined as an empty array input. Maybe we should change the helper?
There was a problem hiding this comment.
It does handle undefined, but every(undefined, _) ==> true, and then addDeprecatedSuggestion crashes on the next line.
This fix is shorter than target.declarations && every(target.declarations, ... and uses the standard utility, so I think it's better.
|
@typescript-bot cherry-pick this to 4.2 |
|
Heya @sandersn, I couldn't find the branch '4.2' on Microsoft/TypeScript. You may need to make it and try again. |
|
@typescript-bot cherry-pick this to release-4.2 |
Component commits: 9f9825a Fix: checkAliasSymbol crash when checking for @deprecated It's possible that we shouldn't be creating symbol with no declarations from non-homomorphic mapped types, but for 4.2, the right fix is to make the @deprecated-check in checkAliasSymbol ensure that target.declarations is defined. 75449de Add bug number and accept baselines
Component commits: 9f9825a Fix: checkAliasSymbol crash when checking for @deprecated It's possible that we shouldn't be creating symbol with no declarations from non-homomorphic mapped types, but for 4.2, the right fix is to make the @deprecated-check in checkAliasSymbol ensure that target.declarations is defined. 75449de Add bug number and accept baselines Co-authored-by: Nathan Shively-Sanders <nathansa@microsoft.com>
It's possible that we shouldn't be creating symbol with no declarations from non-homomorphic mapped types, but for 4.2, the right fix is to make the @deprecated-check in checkAliasSymbol ensure that target.declarations is defined.
Fixes #42957, test case based on
@types/http-errors