-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Node ESMLike ES Modules, but specific to Node.js support (cts, cts, mjs, mts)Like ES Modules, but specific to Node.js support (cts, cts, mjs, mts)Fix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Here's a quick way you can clone this repro locally
https://github.com/DanielRosenwasser/daniel-ts-repros/
cd daniel-ts-repros
git checkout nodenext-package-watch-bug
// src/fileA.ts
import { foo } from "./fileB.mjs";
foo();
// src/fileB.mts
export function foo() {
}
// src/tsconfig.json
{
"compilerOptions": {
"target": "es2016",
"module": "Node16",
"outDir": "../out"
}
}
// package.json
{
"name": "nodenext-package-watch-bug",
"version": "1.0.0",
"description": "Repro",
"author": "Daniel"
}
Currently this produces the following result in the editor or in --watch
mode:
Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.ts
If you add a "type": "module"
to the package.json
, then the error will not go away until you restart tsc
or TS Server.
- "author": "Daniel"
+ "author": "Daniel",
+ "type": "module"
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Node ESMLike ES Modules, but specific to Node.js support (cts, cts, mjs, mts)Like ES Modules, but specific to Node.js support (cts, cts, mjs, mts)Fix AvailableA PR has been opened for this issueA PR has been opened for this issue