testdouble / quibble

Makes it easy to replace require'd dependencies.
94 stars 25 forks source link

TypeScript Support #107

Closed wellwelwel closed 5 months ago

wellwelwel commented 8 months ago

First of all, thank you for this project!

It's amazing, I could easily create a mock for both ESM and CJS with the same code, by just changing from quibble() to quibble.esm()

Also, it's really great that we can use quibble with the native Node.js CLI (node ./my-file.js) 🚀


About Typings

I would like to ask if a PR introducing typings (an index.d.ts, for example) would be welcome 🙋🏻‍♂️


Why

To use quibble in a TypeScript project, first I need to create an any for it by creating a quibble.d.ts in the same level as the src, for example:

declare module 'quibble' {
  const quibble: any;
  export default quibble;
}
searls commented 8 months ago

Thanks for the note. I don't use typescript, but if someone was willing to take on the task of doing it well I'd appreciate it. I'd probably point them to testdouble.js, where the community has provided a typing file that's been iterated on over time, as a starting point