-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
@@ -37124,7 +37124,7 @@ namespace ts { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pffffff okay. Yeah.
@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 <[email protected]>
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