Skip to content

TS: make it easier for a node.js user to leverage typescript #47321

@bpasero

Description

@bpasero

I recently went through the process of writing a new node module and I gave it a try using TypeScript. Even though I am a developer on VSCode I had to leave Code to search for a solution how to get Intellisense to work for the built in node modules.

Steps:

  • create a fresh folder
  • add a simple package.json
  • add a simple index.ts file (see contents below)
  • notice an error around the import
  • find no advice how to fix it

The actual fix was to add @types/node as a dependency but we should offer this to the user when we detect that a built in node module is being used. It is especially weird because we seem to offer this for other 3rd party modules that you add later on.

index.ts

var fs = require("fs");

Result:
image

I am tempted to mark this "important" because I think a lot of users will stop trying TypeScript after they went as far as I did without searching for the solution. And I think node.js with TypeScript users are one of our main target audience.

It could well be that this issue has to move to the TypeScript repo, but I start here.

Metadata

Metadata

Assignees

Labels

typescriptTypescript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions