Open aminya opened 3 years ago
@orta @sandersn Could you take a look at this?
To fix #58, I would prefer to add a new option instead of changing what --expression-file means.
I wanted to call this --file
but it is already taken (it should have been --output-file
. Maybe --input-file
is a good name.
It's likely that the fix for #65 will be more complicated, since it will have to retain the eval-last-expression behaviour of --expression-file.
There is no such requirement. People use --expression-file
as a workaround because there is no other way to generate types for a file. Even if we removed this option, I doubt anyone would complain.
@sandersn Should we fix #169?
How can I build and try this branch?
I can publish this on npm if you like. It is more maintained than dts-gen.
That'd be great.
Here you go. I have published it until this is merged:
npm install -g @aminya/dts-gen
dts-gen --expression-file=./your_file.js
Anyone?
Use it until this is merged:
Description
It fixes
expression-file
to support any JavaScript file as the input.Fixes #58 Fixes #65 Fixes #105
Reasoning
It seems that
eval
acts buggy when it comes to resolving dependencies. Butrequire
doesn't have this issue as it is just what Node uses by default. Also,path.resolve
is needed before passing the file path torequire
.Suggestion
If I could, I would have renamed
expression-file
tofile
and renamed the currentfile
argument tooutput-file
. The naming of the arguments is inaccurate and confusing.