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.

Publish Typescript declaration file

See original GitHub issue

Hi @dumbmatter.

Thanks for such an awesome module! I’m currently using this for some tests in a library of mine that I’m transitioning from JavaScript to Typescript. I was wondering if it would be possible to push a new release out with some Typescript declaration files. It shouldn’t be too hard to do since you’re using Typescript yourself. Just setting declaration: true and removing allowJs: true in tsconfig.json should do the trick.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dumbmattercommented, Jul 12, 2021

@Dahaden thanks for the suggestion and the prototype code!

The problem I worry about with this is if you’re passing around IndexedDB variables in your application code, that code shouldn’t have to care that fake-indexeddb exists, so any difference in types between fake-indexeddb and IndexedDB could result in a lot of false positive TypeScript errors. Extension of your example.

Ultimately I think there’s not much to gain by doing anything other than using the built-in TypeScript IndexedDB types. Anything in fake-indexeddb that’s not in real IndexedDB is not part of the public API currently anyway. (For your example, IDBTransaction.commit actually does exist.) If eventually stuff is added to the public API like #50 or #51, then the fake-indexeddb types could just be like IDBFactory & { myAPI: () => void }.

I’m going to try to do a new release containing TypeScript types and maybe also moving to ES modules if that doesn’t cause too many issues. Working on that now in the v4 branch: https://github.com/dumbmatter/fakeIndexedDB/tree/v4

1reaction
dumbmattercommented, Jun 29, 2021
// @ts-ignore
import "fake-indexeddb/auto";
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: ... Both TypeScript and JavaScript projects can generate types via...
Read more >
Including declarations in your npm package - TypeScript
There are two main ways you can publish your declaration files to npm: bundling with your npm package, or; publishing to the @types...
Read more >
Why publish the TypeScript declaration file on DefinitelyTyped ...
Type declaration publishing guides seem a bit outdated and sparse in several areas. I'll try to compare both scenarios in detail.
Read more >
A quick introduction to “Type Declaration” files and adding ...
These libraries are nothing but the declaration files provided by the TypeScript. We can also explicitly include type declarations in the ...
Read more >
The 30-second guide to publishing a TypeScript package to ...
This tells TypeScript to emit an .d.ts definitions file along with your compiled JavaScript, which is what TypeScript will use for type ...
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