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"
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-bugCurrently this produces the following result in the editor or in
--watchmode:If you add a
"type": "module"to thepackage.json, then the error will not go away until you restarttscor TS Server.