question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update package.json types to reference index.d.ts

See original GitHub issue

Currently 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
catccommented, Oct 19, 2021

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

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.

0reactions
lencionicommented, Oct 20, 2021

I think so!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found