aseemk / requireDir

Node.js helper to require() directories.
MIT License
484 stars 60 forks source link

Add support for TypeScript #42

Closed ryanwe closed 7 years ago

ryanwe commented 7 years ago

Explicitly ignore any type declaration files. While not explicitly a problem, this causes issues when running TypeScript via ts-node. See https://github.com/TypeStrong/ts-node/pull/207 for more details.

aseemk commented 7 years ago

Thank you! 🙏

brandonros commented 5 years ago

What about adding an index.d.ts file to the root directory of the repo so that it is possible to import * as requireDir from 'require-dir'?

yocontra commented 5 years ago

@brandonros Haven't seen that done before, don't think that is necessary

brandonros commented 5 years ago

It is. Try to import * as requireDir from 'require-dir' from any TypeScript project. It will throw an error about a lacking module declaration. You can either add it to the repo like https://github.com/axios/axios/blob/master/index.d.ts or create @types/require-dir (like https://www.npmjs.com/package/@types/express)

yocontra commented 5 years ago

@brandonros Yep typings I understand - I would rather go that route. I don't use typescript, but if somebody else wants to do them it should be a pretty simple API to model.