mkdist icon indicating copy to clipboard operation
mkdist copied to clipboard

fix!: declaration extensions should correspond to their js extension

Open cjpearson opened this issue 11 months ago • 3 comments

This is a partial fix for #138. (Wasn't sure if I should split it out into a new bug) It addresses the issue where changing the extension of the output does not affect extension of the declaration so there is a mismatch. It does not implement automatically choosing the extension based on the source file.

The other important thing is that .ts, .cts, .mts on the declaration files imply the existence of the file with the same basename: that is, index.d.ts says ‘the declaration file is for index.js’, a.d.cts is ‘for a.cjs’, and b.d.mts is ‘for b.mjs’.

https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution

The change itself is relatively straightforward, but it does have a large impact, especially because mjs is the default extension for esm output. Perhaps a major bump would be necessary or hiding the behavior behind a flag?

cjpearson avatar Dec 13 '24 20:12 cjpearson