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

An error occurs when debugging a TypeScript project #3199

Closed
v-ruizh opened this issue May 27, 2022 · 10 comments · Fixed by #3212
Closed

An error occurs when debugging a TypeScript project #3199

v-ruizh opened this issue May 27, 2022 · 10 comments · Fixed by #3212
Labels
AT-CTI Created by CTI team

Comments

@v-ruizh
Copy link

v-ruizh commented May 27, 2022

OS: All
Build Version: 20220526.13

Repro Steps:

  1. Create a TypeScript project with HttpTrigger function.
  2. Debug it.
  3. Check whether succeeds to debug the project or not.

Expect:
Succeed to debug a TypeScript project.

Actual:
An error occurs when debugging a TypeScript project.
image

More Info:
This issue does not reproduce after executing command "npm i --save-dev @types/node".

@v-ruizh v-ruizh added the AT-CTI Created by CTI team label May 27, 2022
@alexweininger
Copy link
Member

alexweininger commented May 27, 2022

This reproduces on v1.7.1 also. Seems like a templates issue

@ejizba
Copy link
Contributor

ejizba commented May 27, 2022

This was due to a recent release of the "@azure/functions" types package which references "Buffer" for the first time. Filed this issue to investigate if we can fix on the types side, but I'm not optimistic: Azure/azure-functions-nodejs-worker#587

The "template" for TypeScript projects is owned by the VS Code extension, so it might be on the extension to address. We went back and forth on whether "@types/node" should be included in TypeScript projects by default in the past (for example here), but that was when @azure/functions didn't reference any node types. The main problem is knowing which version to pick.

@alexweininger
Copy link
Member

A postinstall script could check the installed node version and install the corresponding @types/node package.

@ejizba
Copy link
Contributor

ejizba commented May 27, 2022

Do you have examples of other types packages doing that? I don't really want to re-invent the wheel here as I think it's a very common thing for types packages to reference node types. I'd rather just follow what other popular packages are doing

@alexweininger
Copy link
Member

Do you have examples of other types packages doing that?

Yeah I don't have any examples. 😄

I just tested out enabling the skipLibCheck option in the tsconfig.json and it makes the error go away. Maybe the template could enable that by default?

I know that's not optimal, but TypeScript is exploring better options for skipLibCheck.

@ejizba
Copy link
Contributor

ejizba commented Jun 6, 2022

@alexweininger Would you be fine if we add @types/node to the default template in VS Code? I think that's the most common solution. For example if I do yo code for a new VS Code extension it'll have @types/node set to 16.x. It's a bit more complicated for Functions because of the version matrix, but I'd probably do some mix of trying to match the user's local version and using known versions that are supported for Functions.

If you're fine with the change, I'm happy to submit a PR myself. I will have to make the same change in core tools as well

@bwateratmsft
Copy link
Contributor

I think it would be sensible to do that, with either v16 (active LTS) or v14 (maintenance LTS). Everything below 14 is out-of-support, so I don't feel bad if we scaffold e.g. v14 and a user on v12 has issues. They should not be on v12.

@alexweininger
Copy link
Member

Sounds good to me 👍

@v-ruizh
Copy link
Author

v-ruizh commented Jun 7, 2022

Verified this issue on the extension build 20220606.8, it has been fixed.

@alexweininger
Copy link
Member

Thank you @v-ruizh!

@microsoft microsoft locked and limited conversation to collaborators Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AT-CTI Created by CTI team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants