Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for typedoc.ts, typedoc.cts and typedoc.mts config files #2913

Open
scripthunter7 opened this issue Mar 21, 2025 · 2 comments
Open

Comments

@scripthunter7
Copy link

Search Terms

mts cts config file options

Problem

Currently, TypeScript-based config files aren’t supported, but adding support would be beneficial for several reasons. First, it would allow users to keep all their config files consistently written in TypeScript. Second, it would enable importing from other TypeScript files — for example, reading entry points from a Rollup config that’s also written in TypeScript.

Currently, the workaround is to use TypeDoc programmatically, which allows me to access anything that’s already in TypeScript. However, it would be much more convenient to just use the CLI and import everything I need directly in the config file.

Suggested Solution

Please consider adding support for typedoc.ts, typedoc.cts and typedoc.mts config files according to https://www.typescriptlang.org/docs/handbook/modules/reference.html#module-format-detection

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 21, 2025

I'm definitely leaning towards a wontfix for this one.

Rollup is able to do this because its job is literally to transform source code. It bundles your config file and then executes that.

While TypeDoc wraps TypeScript, which can emit transformed JS, doing so in the config file would require that TypeDoc infer some sort of config and use that... and also be responsible for hooking in to Node's APIs to do the transformation. There is a reason that ts-node is no longer maintained - the Node APIs for that are not stable, at least for all current LTS releases. I want to spend what time I have for typedoc working on typedoc, not fighting Node because some API changed.

Furthermore, recent Node versions are adding flags so that they handle type stripping automatically. Anything added in TypeDoc in the meantime is likely wasted work as Node is can already import TS files in a large number of cases. I'm not at a computer right now, but I'm fairly certain that you could point typedoc at a TS config file with Node 23 and see things work.

@electrovir
Copy link

This can be accomplished trivially by installing tsx and adding NODE_OPTIONS="--import tsx" before your typedoc call:

NODE_OPTIONS="--import tsx" npx typedoc --options typedoc.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants