hocus-pocus
hocus-pocus copied to clipboard
Create Function with Types crashes when argument is an array
Describe the bug
When using the "Create function" (with types) action on a function that takes an array the action is not provided as a code fix. If I execute it via the command palette I receive an error:
// hocuspocus.ts
function bla() {
const c: number[] = [1, 2, 3];
doSomething(c);
}
Select doSomething
and perform the action ->
Something went wrong: Error: Cannot find module 'typescript'
Require stack:
- /home/tobias/.vscode/extensions/nicoespeon.hocus-pocus-1.4.0/out/extension.js
- /usr/share/code/resources/app/out/vs/loader.js
- /usr/share/code/resources/app/out/bootstrap-amd.js
- /usr/share/code/resources/app/out/bootstrap-fork.js
How to reproduce
Just copy the above code into a .ts file and perform the action on doSomething
.
Expected behavior
It should generate the function with the correct param type, in this case number[]
.
Additional information
- Version of the extension impacted: v1.4.0
Here's my installed TS versions if it helps:
# TS not installed globally
tobias@tobias-Precision-3541:~/git/lofino-backend$ npm ls -g | grep typescript
│ │ │ │ ├─┬ @babel/[email protected]
│ │ │ │ │ └─┬ @babel/[email protected]
tobias@tobias-Precision-3541:~/git/lofino-backend$ npm ls | grep typescript
├─┬ @typescript-eslint/[email protected]
│ ├─┬ @typescript-eslint/[email protected]
│ │ ├── @typescript-eslint/[email protected] deduped
├─┬ @typescript-eslint/[email protected]
│ ├── @typescript-eslint/[email protected] deduped
│ ├─┬ @typescript-eslint/[email protected]
├── [email protected]
Weird, "typescript"
is part of the dependencies. Also, it worked during debug. I didn't tested the compiled version, maybe the issue lies in prod bundle 🤔
Thanks for reporting!
FYI I'm also running into this