support `allowArbitraryExtensions`
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Enabling [`allowAbitraryExtensions`](https://www.typescriptlang.org/tsconfig/#allowArbitraryExtensions) defines DTS files as `.d.{extension}.ts`.
I'm trying to create strongly-typed JSON files by generating a `.d.json.ts` for each one I need strong types for (until we get [importing JSON `as const`](https://github.com/microsoft/TypeScript/issues/32063)).
tsup doesn't seem to skip these files when generating DTS and instead assumes they're a TS file to be built, but then dies on the `declare const` syntax.
```
DTS Build error
Unexpected token (Note that you need plugins to import files that are not JavaScript)
1: declare const abi: [
^
2: {
3: "type": "function",
```
(oddly this nice error shows up for tsup version ^6.7.0 but not ^8.2.4 and instead only shows "DTS Build error" with no details)
I've tried to work around this with various ignore/exclude options, but nothing seems to work. The TS maintainers suggest that tsup is missing support for the `.d.{extension}.ts` format enabled by `allowArbitraryExtensions` (see conversation in https://github.com/microsoft/TypeScript/issues/49703#issuecomment-2289724261).
Contributor guide
Research direction
Reproduce the failure with a generated `.d.json.ts` file and trace tsup's DTS build path, focusing on how declaration files are identified. Done means files using the `.d.{extension}.ts` format are skipped or handled correctly during DTS generation, with useful error details preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100