microsoft / dts-gen

dts-gen creates starter TypeScript definition files for any module or library.
MIT License
2.43k stars 101 forks source link

Unexpected crash trying to build types for @google-cloud/... #138

Open dcramb opened 5 years ago

dcramb commented 5 years ago

Command line:

% dts-gen -m @google-cloud/nodejs-repo-tools

Result:

Unexpected crash! Please log a bug with the commandline you specified. /usr/local/lib/node_modules/dts-gen/bin/lib/run.js:125 throw e; ^

Error: ENOENT: no such file or directory, open '@google-cloud/nodejs-repo-tools.d.ts' at Object.openSync (fs.js:447:3) at Object.writeFileSync (fs.js:1206:35) at Object. (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:107:12) at Module._compile (internal/modules/cjs/loader.js:774:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10) at Module.load (internal/modules/cjs/loader.js:641:32) at Function.Module._load (internal/modules/cjs/loader.js:556:12) at Function.Module.runMain (internal/modules/cjs/loader.js:837:10) at internal/main/run_main_module.js:17:11 { errno: -2, syscall: 'open', code: 'ENOENT', path: '@google-cloud/nodejs-repo-tools.d.ts' }

When I explicitly state the output file:

% dts-gen -m @google-cloud/nodejs-repo-tools -f nodejs-repo-tools.d.ts

it works fine. I suspect the issue is the @ in the path when writing the output. I tried escaping it but same result. Note, I get the same issue with the -d option

benjamingr commented 5 years ago

You need to specify the output file name since by default it would use the input package name which does not make for a valid file name.

pdeschen commented 4 years ago

@dcramb give it a shot creating the @google folder first

mkdir @google
dts-gen -m @google-cloud/nodejs-repo-tools

I had the same issue with some other namespaced module and creating the namespace dir first works around the issue.

However, I think dts-gen should figure it out :-)