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

TypeError: host.isKnownTypesPackageName is not a function #41962

Closed
edsrzf opened this issue Dec 15, 2020 · 1 comment · Fixed by #42050
Closed

TypeError: host.isKnownTypesPackageName is not a function #41962

edsrzf opened this issue Dec 15, 2020 · 1 comment · Fixed by #42050
Labels
Bug A bug in TypeScript Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19
Milestone

Comments

@edsrzf
Copy link

edsrzf commented Dec 15, 2020

TypeScript Version: 4.1.3

Search Terms: getTypesPackageNameToInstall, isKnownTypesPackageName

Code

Because this happens while using the API, I've created a GitHub repo that reproduces this issue: https://github.com/edsrzf/ts-codefix-repro

Note that I have not been able to reproduce it within an editor, such as VSCode.

Expected behavior:

LanguageService.getCodeFixesAtPosition returns code fixes and does not throw an exception when passed valid parameters.

Actual behavior:

LanguageService.getCodeFixesAtPosition throws an exception with this stack trace:

TypeError: host.isKnownTypesPackageName is not a function
    at getTypesPackageNameToInstall (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:138180:25)
    at Object.getCodeActions (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:138144:40)
    at /Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:134099:77
    at Object.flatMap (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:707:25)
    at Object.getFixes (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:134099:23)
    at /Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:147608:35
    at Object.flatMap (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:707:25)
    at Object.getCodeFixesAtPosition (/Users/edsrzf/projects/ts-new-repro/node_modules/typescript/lib/typescript.js:147606:23)
    at main (/Users/edsrzf/projects/ts-new-repro/script.js:9:37)

Playground Link: No playground link, but again there's this GitHub repo: https://github.com/edsrzf/ts-codefix-repro

Related Issues: #18217

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 15, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 15, 2020
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Dec 15, 2020
@sandersn sandersn added the PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 label Dec 15, 2020
@chenjigeng
Copy link
Contributor

chenjigeng commented Dec 19, 2020

@edsrzf This PR fixes the problem of error reporting, but if you want to return code fixes correctly, You should ask the author
of @ts-morph to add the isKnownTypesPackageName function. I have submitted another PR to @TS-Morph to support this option, you can help to have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants