Skip to content

When using addRelativeDeclarationExtensions, the extension should be based on the extension of the output file #264

@cjpearson

Description

@cjpearson

Environment

[email protected]
node 20.9.0

Reproduction

  • Set the output extension to mjs or cjs, enable outputting declarations and enable addRelativeDeclarationExtensions
  • Have a file which imports from another file
  • Build and review the definitions

Describe the bug

When compiling a .ts file to .mjs or .cjs, the declaration for the file should be .d.mts or .d.cts accordingly. Additionally, when the declarations include imports with extensions (required for node16), the extension also needs to match. It should be .js in .d.ts files, .cjs in .d.cts files and .mjs in .d.mts files.

Right now the feature just looks at the input file. Typescript would compile a .mts file to .mjs, but since mlly also allows explicitly defining the output extension, it should use that option as the source of truth here as well.

Additional context

#134

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions