hocus-pocus icon indicating copy to clipboard operation
hocus-pocus copied to clipboard

Create Function with Types crashes when argument is an array

Open automatensalat opened this issue 4 years ago • 2 comments

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]

automatensalat avatar May 26 '20 13:05 automatensalat

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!

nicoespeon avatar May 28 '20 20:05 nicoespeon

FYI I'm also running into this

OliverJAsh avatar Jul 05 '20 18:07 OliverJAsh