types-4-strapi-2 icon indicating copy to clipboard operation
types-4-strapi-2 copied to clipboard

Add ECMAScript Module Support

Open exploids opened this issue 1 year ago • 3 comments

The imports/exports generated by this tool are not compatible with ECMAScript Modules out of the box, as they are missing the mandatory file extension. It would be useful to be able to configure this behaviour manually or have the tool resolve the current module system through the tsconfig.json file(s).

Expected output

export * from "./builtins/Media.js";
export * from "./builtins/MediaFormat.js";
export * from "./builtins/RequiredBy.js";
// ...

Actual output

export * from "./builtins/Media";
export * from "./builtins/MediaFormat";
export * from "./builtins/RequiredBy";
// ...

Causes the following error:

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './builtins/Media.js'? ts(2835)

Alternatively, an option to generate all types into a single file without the need for imports/exports could resolve this issue.

exploids avatar Mar 22 '23 10:03 exploids