-
Notifications
You must be signed in to change notification settings - Fork 12.8k
fix: host.isKnownTypesPackageName maybe undefined #42050
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: host.isKnownTypesPackageName maybe undefined #42050
Conversation
The problem is that isKnownTypesPackageName of the host is optional, but in this case it is simply mandatory. After modification, I tried it locally and it work |
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.
Thanks for looking at my issue!
@@ -52,6 +52,6 @@ namespace ts.codefix { | |||
function getTypesPackageNameToInstall(packageName: string, host: LanguageServiceHost, diagCode: number): string | undefined { | |||
return diagCode === errorCodeCannotFindModule | |||
? (JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) | |||
: (host.isKnownTypesPackageName!(packageName) ? getTypesPackageName(packageName) : undefined); // TODO: GH#18217 | |||
: (host.isKnownTypesPackageName?.(packageName) ? getTypesPackageName(packageName) : undefined); // TODO: GH#18217 |
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.
The comment referring to #18217 can be removed now since the non-null assertion is gone.
: (host.isKnownTypesPackageName?.(packageName) ? getTypesPackageName(packageName) : undefined); // TODO: GH#18217 | |
: (host.isKnownTypesPackageName?.(packageName) ? getTypesPackageName(packageName) : undefined); |
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.
Thanks for your suggestion. Done
6c8e7b2
to
c02335e
Compare
@RyanCavanaugh @sandersn Could you please help CR this |
* fix: host.isKnownTypesPackageName maybe undefined * feat: remove GH#18217 comment
Fixes #41962