microsoft / dts-gen

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

No meaningful dts-gen for the @google-cloud/bigquery module #107

Open carlos-bernal-gby opened 6 years ago

carlos-bernal-gby commented 6 years ago

I'm trying to use the @google-cloud/bigquery module with typescript, but found out than it doesn't have typescript support, like @google-cloud/storage does.

So I thought to use the dts-gen tool to create a declaration file, however, there seems to be a problem when a module starts with an @ and an error is thrown.

➜ git:(master-github-origin) ✗ dts-gen -m @google-cloud/bigquery
Unexpected crash! Please log a bug with the commandline you specified.
/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:130
        throw e;
        ^

Error: ENOENT: no such file or directory, open '@google-cloud/bigquery.d.ts'
    at Object.fs.openSync (fs.js:667:18)
    at Object.fs.writeFileSync (fs.js:1326:33)
    at Object.<anonymous> (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:112:12)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)
    at Function.Module.runMain (module.js:703:10)
    at startup (bootstrap_node.js:193:16)

Found in the issues section that I should use the -f parameter. Doing so creates the .d.ts file successfully but only with 3 lines and no declarations, thus it cannot be used, and a TS compiler error is launched.

➜  ga-downloader git:(master-github-origin) ✗ dts-gen -m @google-cloud/bigquery -f test.d.ts
Wrote 3 lines to test.d.ts.

/** Declaration file generated by dts-gen */

export = @google_cloud/bigquery;

src/declaration-files/test.d.ts(3,10): error TS1109: Expression expected.
src/declaration-files/test.d.ts(3,23): error TS1146: Declaration expected.
src/declaration-files/test.d.ts(3,24): error TS1161: Unterminated regular expression literal.

Could this be a dts-gen problem? or is there something I'm missing?