Skip to content

VS Code/language server doesn't properly detect NodeNext module kind based on package.jsonΒ #47806

Closed
@niklashigi

Description

@niklashigi

Bug Report

πŸ”Ž Search Terms

  • typescript nodenext errors only reported by tsc
  • typescript nodenext errors not reported by vs code

πŸ•— Version & Regression Information

I noticed this in 4.6.0-dev.20220208 and didn't try earlier versions because the NodeNext module kind hasn't been included in a stable release yet.

⏯ Playground Link

Can't be reproduced in the Playground.

πŸ’» Code

Reproducing the bug doesn't require specific code, but rather a specific TypeScript and VS Code setup, so I created a reproduction repo. Here's what's necessary to reproduce the issue:

  • Clone the repo
  • Install the dependencies
  • Open the project in VS Code
  • Make VS Code use the workspace TypeScript version (4.6.0-dev.20220208)
  • Compile the code with yarn tsc or npx tsc
  • Open the src/index.ts file in VS Code

πŸ™ Actual behavior

tsc tells us about the ESM-specific Relative import paths need explicit file extensions... error in src/index.ts while VS Code doesn't. This is likely because tsc correctly detects the file's module kind to be NodeNext based on the package.json while the language server doesn't for some reason.

πŸ™‚ Expected behavior

Both tsc and VS Code report the error because they both realize that the file is a NodeNext module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions