index.d.ts 432 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. Import a module while bypassing the cache.
  3. @example
  4. ```
  5. // foo.js
  6. let i = 0;
  7. module.exports = () => ++i;
  8. // index.js
  9. import importFresh = require('import-fresh');
  10. require('./foo')();
  11. //=> 1
  12. require('./foo')();
  13. //=> 2
  14. importFresh('./foo')();
  15. //=> 1
  16. importFresh('./foo')();
  17. //=> 1
  18. const foo = importFresh<typeof import('./foo')>('./foo');
  19. ```
  20. */
  21. declare function importFresh<T>(moduleId: string): T;
  22. export = importFresh;