Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Dec 9, 2025

The jsii compiler used to require that package.json#types was specified, usually set to index.d.ts.

The upstream TypeScript compiler doesn't require this, and just defaults to either index.ts or index.d.ts, whichever one is available.

In fact, the forcing of a "types": "index.d.ts" entry into package.json makes compilation harder:

If user code happens to import the package root directory (via import { Symbol } from '../..' or the like) TypeScript module resolution will find the package.json, read the "types" entry from it, and add that to the source list.

This will then lead to index.d.ts to be added to the set of source files, instead of index.ts.

That will then most likely lead to the error:

Cannot write file 'index.d.ts' because it would overwrite input file.

Relieve the restriction on the presence of this field. It's unnecessary, and its presence messes up compilation in some cases.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The `jsii` compiler used to require that `package.json#types` was
specified, usually set to `index.d.ts`.

The upstream TypeScript compiler doesn't require this, and just defaults
to either `index.ts` or `index.d.ts`, whichever one is available.

In fact, the forcing of a `"types": "index.d.ts"` entry into
`package.json` makes compilation harder:

If user code happens to import the package root directory (via `import {
Symbol } from '../..'` or the like) TypeScript module resolution will
find the `package.json`, read the `"types"` entry from it, and add that
to the source list.

This will then lead to `index.d.ts` to be added to the set of source
files, instead of `index.ts`.

That will then most likely lead to the error:

```
Cannot write file 'index.d.ts' because it would overwrite input file.
```

Relieve the restriction on the presence of this field. It's unnecessary,
and its presence messes up compilation.
@rix0rrr rix0rrr requested a review from a team December 9, 2025 14:23
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.

1 participant