Skip to content
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

Merged

Conversation

chenjigeng
Copy link
Contributor

Fixes #41962

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 19, 2020
@chenjigeng
Copy link
Contributor Author

chenjigeng commented Dec 19, 2020

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

Copy link

@edsrzf edsrzf left a 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
Copy link

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.

Suggested change
: (host.isKnownTypesPackageName?.(packageName) ? getTypesPackageName(packageName) : undefined); // TODO: GH#18217
: (host.isKnownTypesPackageName?.(packageName) ? getTypesPackageName(packageName) : undefined);

Copy link
Contributor Author

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

@chenjigeng chenjigeng force-pushed the fix/isKnownTypesPackageName-undefined branch from 6c8e7b2 to c02335e Compare December 20, 2020 07:44
@chenjigeng
Copy link
Contributor Author

@RyanCavanaugh @sandersn Could you please help CR this

@sandersn sandersn added this to Not started in PR Backlog Dec 30, 2020
PR Backlog automation moved this from Not started to Needs merge Dec 30, 2020
@sandersn sandersn merged commit ea93ee6 into microsoft:master Dec 30, 2020
PR Backlog automation moved this from Needs merge to Done Dec 30, 2020
Zzzen pushed a commit to Zzzen/TypeScript that referenced this pull request Jan 16, 2021
* fix: host.isKnownTypesPackageName maybe undefined

* feat: remove GH#18217 comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
PR Backlog
  
Done
Development

Successfully merging this pull request may close these issues.

TypeError: host.isKnownTypesPackageName is not a function
4 participants