microsoft / vscode-generator-code

Visual Studio Code extension generator
Other
1.31k stars 225 forks source link

`yo code` template produces code that won't compile #377

Closed AArnott closed 1 year ago

AArnott commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Follow instructions at https://code.visualstudio.com/api/get-started/your-first-extension to get yo
  2. Run yo code and indicate that you want to create a new VS Code extension (TypeScript). Complete the interview process (I used yarn).
  3. Run yarn pretest

Expected

Successful compilation

Actual

Compilation failure:

yarn run v1.22.19
$ yarn run compile-tests && yarn run compile && yarn run lint
$ tsc -p . --outDir out
node_modules/@types/node/ts4.8/stream.d.ts:842:39 - error TS2304: Cannot find name 'Blob'.

842             static from(src: Stream | Blob | ArrayBuffer | string | Iterable<any> | AsyncIterable<any> | AsyncGeneratorFunction | Promise<any> | Object): Duplex;
                                          ~~~~

Found 1 error in node_modules/@types/node/ts4.8/stream.d.ts:842

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The 'fix' I've found is to add dom to the compilerOptions.lib array in tsconfig.json. But shouldn't the template compile out-of-the-box?

scruel commented 2 years ago

+1

AArnott commented 2 years ago

@scruel tip: use a github thumbs up reaction to the original issue rather than posting +1 in a comment. It aggregates much better, giving the repo maintainers a quick idea of size of interest.

scruel commented 2 years ago

@AArnott Ok, thank you for your advice.

chapma26 commented 2 years ago

I had the same issue. "npm update -g" fixed it for me. I had a slightly older typescript and updating seemed to resolve the issue.

AArnott commented 2 years ago

@chapma26 given this no longer repros for me, I suspect you may be right. Although I'm disappointed that it would use the global tsc npm package instead of a local one, for many reasons including avoiding an issue like this.

AArnott commented 2 years ago

Never mind. It no longer repros for me with a new yo code directory, but my existing one where it was failing before still fails, even after ensuring I'm using the latest typescript compiler. I suspect something has changed in the yo template to fix this, but diffing the latest against what I had when I filed this, I can't find any significant change.

aeschli commented 1 year ago

It was a bug in @types/node: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62672