yortus / require-self

Lets you require('foobar') from within foobar itself
MIT License
19 stars 5 forks source link

Typescript declaration #14

Closed papertiger12 closed 3 years ago

papertiger12 commented 4 years ago

First off, thanks for this project, it saved me tons of manual steps. This isn't really an issue, but might be worth adding to the README. I just wanted to post this incase anyone else uses this repo within a typescript project.

In order for the import to provide the proper declarations you need to add a declaration to your project typings:

<root>/typings/index.d.ts

declare module 'foobar';

where foobar is the name from your package.json

yortus commented 4 years ago

Hi @papertiger12. Are you using the current version (v0.2.3)? It supports typescript, so you shouldn't need to add any declarations for it to work.

You might need to delete the generated foobar.js from node_modules and run this script again for it to work (I just noticed a flaw in this script where it won't write the foobar.d.ts file if the foobar.js file already exists - a PR to fix that would be welcome).