Update package.json types to reference index.d.ts
See original GitHub issueCurrently index.ts
is being used as types
in package.json which is causing compiler errors when upgrading to newer versions of typescript (since it tries to compile the entire package instead of just referencing the types). I think this could be resolved by generating an index.d.ts
and referencing that instead.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Documentation - Publishing - TypeScript
There are two main ways you can publish your declaration files to npm: ... file is named index.d.ts and lives at the root...
Read more >What to put in package.json types field for typescript based libs
json "types" field? According to: Typescriptlang.org/publishing.html. I should put a reference to my generated index.d.ts like so:
Read more >index.d.ts should be the only d.ts file allowed in tsconfig.json
Currently, tsconfig.json for each package contains all the test files and all the ... Only index.d.ts should be allowed of the types files:....
Read more >Including declarations in your npm package - TypeScript
Note that the "typings" field is synonymous with "types" , and could be used as well. Also note that if your main declaration...
Read more >TypeScript configuration - Angular
At the root tsconfig.json file specifies the base TypeScript and Angular ... Use TypeScript type definition files — d.ts files — to tell...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue with the
index.ts
file is that if it fails to compile on newer ts versions, you can’t really fix those errors because it’s in the package source code.See source![Screen Shot 2021-10-19 at 12 18 02 PM](https://user-images.githubusercontent.com/5651132/137980781-78344439-583e-4bbd-a083-a90392d7c760.png)
With
index.d.ts
, you’re just referencing the type declarations so ts won’t actually try to compile the source code and fail; any errors will be in the consuming/parent code using the package, if this makes sense.I think so!