Skip to content

Handle .mts and .cts files as TypeScript in paperwork - #168

Open
bardrop wants to merge 1 commit into
dependents:mainfrom
bardrop-oss:fix-paperwork-mts-cts
Open

bardrop wants to merge 1 commit into
dependents:mainfrom
bardrop-oss:fix-paperwork-mts-cts

Conversation

@bardrop

@bardrop bardrop commented Nov 12, 2026

Copy link
Copy Markdown

Fixes #167.

paperwork() turns the extension into the type by stripping the dot, so .mts and .cts became mts and cts, which getDetective does not know. No detective ran and these files always returned [] (so dependency-tree and madge saw no dependencies).

Now:

  • .mts maps to ts, the same as .ts. Options under ts (like skipTypeImports) apply.
  • .cts maps to ts too. Because .cts files are CommonJS, ts.mixedImports defaults to true for them, so const x = require('./x.cjs') is found (this is what the issue expects for c.cts). Passing ts: { mixedImports: false } turns that off. If you would rather keep .cts exactly like .ts (no require() by default), I can drop that part.

The if/else chain became a switch, because xo's unicorn/prefer-switch asks for one once there are more branches. Behavior for the other extensions is the same. The README line on extension mapping is updated.

Tests: 4 new paperwork tests with .mts/.cts fixtures (all fail on main). npm test (xo, type check, vitest: 57 tests) passes.

paperwork used the extension without the dot as the type, and there is
no detective for mts or cts, so these files always had no dependencies.
Map both to ts. .cts files are CommonJS, so ts.mixedImports defaults to
true for them and require() calls are found.

Fixes dependents#167
@bardrop

bardrop commented Nov 19, 2026

Copy link
Copy Markdown
Author

Friendly ping when you have time. Is there anything you'd like changed here?

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

Successfully merging this pull request may close these issues.

paperwork() returns no dependencies for .mts and .cts files

1 participant