When using the config.typesFile option in a TypeScript project with moduleResolution set to node16 or nodenext, this package will always cause an error when building the project. This is because TypeScript expects local imports to have a .js extension. For example this config:
config: {
typesFile: "types/generated"
}
will generate an import like this:
import { Type1, Type2 } from "types/generated";
which will in turn result in the error:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean 'types/generated.js'?
And you can't work around it by appending the .js yourself:
When using the
config.typesFile
option in a TypeScript project withmoduleResolution
set tonode16
ornodenext
, this package will always cause an error when building the project. This is because TypeScript expects local imports to have a.js
extension. For example this config:will generate an import like this:
which will in turn result in the error:
And you can't work around it by appending the
.js
yourself:because the extension is explicitly stripped.
I'm not sure what the permanent solution here is, but I suspect the higher-level config's
emitLegacyCommonJSImports
value should be respected.I worked around this for now by patch-packaging the source code to remove the extension stripping.