GithubHelp home page GithubHelp logo

microsoft / dts-gen Goto Github PK

View Code? Open in Web Editor NEW
2.4K 33.0 106.0 676 KB

dts-gen creates starter TypeScript definition files for any module or library.

License: MIT License

TypeScript 76.37% JavaScript 23.63%

dts-gen's Introduction

dts-gen's People

Contributors

aashutoshrathi avatar adrianbrs avatar andrewbranch avatar bouzuya avatar danielrosenwasser avatar domdomegg avatar exe-boss avatar gongt avatar jakebailey avatar joscha avatar leonard-thieu avatar mhegazy avatar microsoft-github-policy-service[bot] avatar mleko avatar peterblazejewicz avatar roblav96 avatar ryancavanaugh avatar sandersn avatar slavafomin avatar suisse00 avatar thomashickman avatar zalastax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dts-gen's Issues

-f option does not work at all?

Steps:

  • npm install -g dts-gen
  • (Tried with existing .js files, and with a new empty folder)
  • create test.js with the following contents:
    var x = {};
    function TheFunction(y) {
    }
    TheFunction(x);
    
  • dts-gen -f test.js
  • fails with the following error:
      Unexpected crash! Please log a bug with the commandline you specified.
      C:\Users\MY USERNAME\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:109
              throw e;
              ^
    
      Error
          at ArgsError.Error (native)
          at new ArgsError (C:\Users\MY USERNAME\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:25:28)
          at Object.<anonymous> (C:\Users\MY USERNAME\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:39:15)
          at Module._compile (module.js:409:26)
          at Object.Module._extensions..js (module.js:416:10)
          at Module.load (module.js:343:32)
          at Function.Module._load (module.js:300:12)
          at Function.Module.runMain (module.js:441:10)
          at startup (node.js:139:18)
          at node.js:974:3
    

`dts-gen -d yargs` crashes

/home/andy/types/dts-gen/bin/lib/run.js:109
        throw e;
        ^

Error
    at new ArgsError (/home/andy/types/dts-gen/bin/lib/run.js:25:28)
    at Object.<anonymous> (/home/andy/types/dts-gen/bin/lib/run.js:39:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)

Command line always crashes 0.4.20 & 0.4.19

One of the library dependencies is causing dts-gen to crash.

Steps to Reproduce.

npm install -g [email protected]
dts-gen

or

npm install -g [email protected]
dts-gen

results 0.4.20

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

Error
    at new ArgsError (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:25:28)
    at Object.<anonymous> (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:39:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)

Extra Info

OS: Mac OS X 10.12.3
Node: 7.5.0
NPM: 4.2.0

I'll look to see if I can find the cause.

no such file or directory

After installing dts-gen with npm install -g dts-gen running it always triggers the error no such file or directory. It doesn't matter what flags I use of if I use no flags at all.

Running on debian linux with node v5.11.2 and npm 3.8.6

dts-gen -m prosemirror-schema-basic - crash - Maximum call stack size exceeded

$ dts-gen -m prosemirror-schema-basic
Unexpected crash! Please log a bug with the commandline you specified.

/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:87
    keys.sort();
         ^
RangeError: Maximum call stack size exceeded
    at Array.sort (native)
    at getKeysOfObject (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:87:10)
    at getPropertyDeclarationsOfObject (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:251:18)
    at getResult (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:238:37)
    at getTypeOfValue (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:209:17)
    at getResult (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:219:47)
    at getTypeOfValue (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:209:17)
    at getProperty (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:259:45)
    at Array.map (native)
    at getPropertyDeclarationsOfObject (/Users/jtblin/.nvm/versions/node/v7.6.0/lib/node_modules/dts-gen/bin/lib/index.js:252:25)

dts-gen enquire.js - Unexpected crash

yarn list enquire.js
yarn list v0.19.1
└─ [email protected]

dts-gen enquire.js
Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\lukas.gorniak\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:109
throw e;
^

Error
at ArgsError.Error (native)
at new ArgsError (C:\Users\l.g\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:25:28)
at Object. (C:\Users\l.g\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:39:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)

Failed to publish [email protected]?

Missing template option

$ npm i [email protected]
$ npm ls dts-gen
[email protected] ~/test-ts
└── [email protected] 

$ cat node_modules/dts-gen/bin/lib/run.js | head -25
#!/usr/bin/env node
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var guess = require("./");
var yargs = require("yargs");
var fs = require("fs");
var path = require("path");
var args = yargs
    .alias('m', 'module')
    .alias('i', 'identifier')
    .alias('e', 'expression')
    .alias('n', 'name')
    .alias('f', 'file')
    .alias('d', 'dt')
    .alias('s', 'stdout')
    .alias('o', 'overwrite')
    .argv;
var ArgsError = (function (_super) {
    __extends(ArgsError, _super);
    function ArgsError(argsError) {
        var _this = _super.call(this) || this;

Unexpected token [

dts-gen -m yargs
C:\Users\melhamod\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\definitely-typed.js:40
for (const [name, text] of files) {
^

SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (C:\Users\melhamod\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:8:28)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

Unexpected crash: TypeError: Cannot read property 'version' of undefined

To reproduce:

  1. Install dts-gen globally.
  2. Install offline-plugin locally. Ensure that the local node_modules folder is in PATH.
  3. run the following command: dts-gen -m offline-plugin or dts-gen -m "offline-plugin" (in the above directory).

Error:

Unexpected crash! Please log a bug with the commandline you specified.
/home/node/workspace/node_modules/dts-gen/bin/lib/run.js:130
        throw e;
        ^

TypeError: Cannot read property 'version' of undefined
    at Object.get (/home/node/workspace/node_modules/offline-plugin/lib/index.js:741:33)
    at getProperty (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:254:30)
    at Array.map (native)
    at getPropertyDeclarationsOfObject (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:250:25)
    at getTypeOfValue (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:237:33)
    at getResult (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:173:32)
    at getTopLevelDeclarations (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:123:17)
    at getResult (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:148:17)
    at getTopLevelDeclarations (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:123:17)
    at Object.generateModuleDeclarationFile (/home/node/workspace/node_modules/dts-gen/bin/lib/index.js:49:19)

Duplicate identifier 'prototype' : listr

I was trying to generate .d.ts for listr

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

export = listr;

declare class listr {
    constructor(...args: any[]);

    add(...args: any[]): void;

    render(...args: any[]): void;

    run(...args: any[]): void;

    setRenderer(...args: any[]): void;

}

declare namespace listr {
    namespace prototype {
    //        ^^^^^^^^^==============================> problem 
        const tasks: any;

        function add(...args: any[]): void;

        function render(...args: any[]): void;

        function run(...args: any[]): void;

        function setRenderer(...args: any[]): void;

    }

}

says

Duplicate identifier 'prototype'

dts-gen -d -m feathers crashed

Running the command dts-gen -d -m feathers crashed with the following error message:

Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:109
        throw e;
        ^

TypeError: Cannot read property 'statusCode' of undefined
    at IncomingMessage.fresh (C:\Users\cke\Documents\Development\DefinitelyTyped\node_modules\express\lib\request.js:450:19)
    at getProperty (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:264:30)
    at Array.map (native)
    at getPropertyDeclarationsOfObject (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:260:23)
    at getResult (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:246:35)
    at getTypeOfValue (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:217:15)
    at getResult (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:177:30)
    at getTopLevelDeclarations (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at getResult (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:152:17)
    at getTopLevelDeclarations (C:\Users\cke\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)

Unexpected Crash mongo-models

dts-gen --dt --module mongo-models
Unexpected crash! Please log a bug with the commandline you specified.
/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/run.js:130
        throw e;
        ^

TypeError: Cannot read property '3' of undefined
    at Object.get [as generationTime] (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js:346:20)
    at getProperty (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:254:30)
    at Array.map (native)
    at getPropertyDeclarationsOfObject (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:250:25)
    at getTypeOfValue (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:237:33)
    at getResult (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:173:32)
    at getTopLevelDeclarations (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:123:17)
    at getResult (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:148:17)
    at getTopLevelDeclarations (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:123:17)
    at getResult (/home/athroener/.nvm/versions/node/v8.1.0/lib/node_modules/dts-gen/bin/lib/index.js:148:17)

dts-gen for excel4node 1.2.1

I am a newbie in typescript following typescript node starter tutorial. I ran dts-gen on excel4node v1.2.1. The generated d.ts has error at:

export namespace Workbook {
    namespace prototype {
        function addWorksheet(name: any, opts: any): any;

        function createStyle(opts: any): any;

        function getStringIndex(val: any): any;

        function setSelectedTab(id: any): void;

        function write(fileName: any, handler: any): void;

        function writeToBuffer(): any;
...

-- typescript complains "src/types/excel4node.d.ts(475,15): error TS2300: Duplicate identifier 'prototype"

I would guess this is a bug triggered by source code referencing functions explicitly through the prototype property.... Will I be ok if I just delete the offending definition? After all above I see:

export class Workbook {
    constructor(opts: any);

    addWorksheet(name: any, opts: any): any;

    createStyle(opts: any): any;

    getStringIndex(val: any): any;

    setSelectedTab(id: any): void;

    write(fileName: any, handler: any): void;

    writeToBuffer(): any;

}

JavaScript heap out of memory

To reproduce just run dts-gen -m libsodium-wrappers

The package uses crypto so it makes sense it's heavy on ram. Not sure if there is a way to work around this.

Crash more gracefully when using --dt

While dts-gen shouldn't crash, it's just going to sometimes. That's fine, but DefinitelyTyped used to have a script that consistently worked. Now the instructions are to rely on dts-gen entirely, and having just tried it on a library (moonjs), it just crashed.

This package needs to have some sort of general graceful fallback behavior if DefinitelyTyped is going to rely on it. Otherwise we're making it way too annoying/difficult to contribute.

CC @andy-ms @RyanCavanaugh @mhegazy

dts-gen -m angularfire

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

ReferenceError: window is not defined
at Object. (/usr/local/lib/node_modules/angular/angular.js:31766:4)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/usr/local/lib/node_modules/angular/index.js:1:63)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

Unexpected crash when trying to build types for dynamodb [TypedArray.prototype.buffer called on incompatible receiver]

$ dts-gen -m dynamodb                                                                                                                                  1 
Unexpected crash! Please log a bug with the commandline you specified.
/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/run.js:130
        throw e;
        ^

TypeError: Method get TypedArray.prototype.buffer called on incompatible receiver [object Object]
    at Uint8Array.get buffer [as buffer] (<anonymous>)
    at getProperty (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:254:30)
    at Array.map (native)
    at getPropertyDeclarationsOfObject (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:250:25)
    at getTypeOfValue (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:237:33)
    at getResult (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:173:32)
    at getTopLevelDeclarations (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:123:17)
    at getResult (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:148:17)
    at getTopLevelDeclarations (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:123:17)
    at getResult (/Users/marmos91/.nvm/versions/node/v7.10.0/lib/node_modules/dts-gen/bin/lib/index.js:191:35)

Scrape JSDoc when possible

If we can locate the source (either by having the user specify as an additional argument, or grokking node modules ourselves), we can try to line up the function and property jsdoc comments by name and re-attach them in the .d.ts, as well as put in inferred types.

Support lookup in local node_modules

I think that forcing users to do a second install is a real pain since it's already installed. Is there any way we can make this work for a local node_modules folder?

Module names with @ symbol

For example:
dts-gen -m @mapbox/sphericalmercator cannot be working but
dts-gen -m sphericalmercator is working

Unexpected crash when generating *.d.ts files for modules and 'sequelize'

Following error occurred when generating *.d.ts files for module 'sequelize'

C:\Users\pavel\Desktop\node development\card-processer>dts-gen -m sequelize
Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:109
throw e;
^

TypeError: Cannot read property 'getConnectorManager' of undefined
at Sequelize.get (C:\Users\pavel\Desktop\node development\card-processer\node_modules\sequelize\lib\sequelize.js:315:35)
at C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:143
at Array.map (native)
at getClassPrototypeMembers (C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:75)
at getResult (C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:138:17)
at getTopLevelDeclarations (C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
at Object.generateModuleDeclarationFile (C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:49:17)
at Object. (C:\Users\pavel\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:54:24)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)

Unexpected crash for module react-helmet

Just gave dts-gen a try because the react-helmet types from DefinitelyTyped aren't working properly in my React-Redux SPA.

Sady dts-gen -m react-helmet leads to:

Unexpected crash! Please log a bug with the commandline you specified.
dts-gen : C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:109
In Zeile:1 Zeichen:1
+ dts-gen -m react-helmet
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\harald...\lib\run.js:109:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
        throw e;
        ^

TypeError: Cannot convert undefined or null to object
    at isClasslike (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:112:39)
    at getResult (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:135:17)
    at getTopLevelDeclarations (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at getResult (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:198:33)
    at getTopLevelDeclarations (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at getResult (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:152:17)
    at getTopLevelDeclarations (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at Object.generateModuleDeclarationFile (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:49:17)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:54:24)
    at Module._compile (module.js:570:32)

Support "templates" for creating easy stubs

When a library can't load, we should still be able to generate something so that we can use this tool in lieu of explaining everything about how to set up a correct DefinitelyTyped folder

Crash when running dts-gen -m redux-actions

I just tried to generate a .d.ts file for redux-actions and I got the following exception:

Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\ME\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:107
        throw e;
              ^
TypeError: undefined is not a function
    at Object.<anonymous> (C:\Users\ME\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:83:23)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Is there anything I can do to fix this issue?

Unexpected Crash, ReferenceError: window is not defined, dts-gen -m scrollmagic

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

ReferenceError: window is not defined
at /Users/mike/Documents/viewboard/node_modules/scrollmagic/scrollmagic/uncompressed/ScrollMagic.js:37:2
at /Users/mike/Documents/viewboard/node_modules/scrollmagic/scrollmagic/uncompressed/ScrollMagic.js:22:20
at Object. (/Users/mike/Documents/viewboard/node_modules/scrollmagic/scrollmagic/uncompressed/ScrollMagic.js:27:2)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)

basic type induction?

Automatic type induction is available in typescript. Is there a plan to support a subset rules such as string, number, and especially, React.component. e.g. I have to addextends React.Component<any,any> manually to make VScode not complain about the react component class used as .

not starting after installation

I installed dts-gen with

sudo npm install -g dts-gen

then I ran

dts-gen

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

Error
at ArgsError.Error (native)
at new ArgsError (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:25:28)
at Object. (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:39:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)

> npm ---version                             
3.10.8
> node --version            
v6.8.1
> cat /etc/issue          
Ubuntu 16.10 \n \l

Using on script runtime

Is there a way to use the tool in a way similar to that:

import gen from 'dts-gen';
class MyClass {
m1(){}
m2(){}
...
}

const o = new MyClass()

gen(o)

?

Error: jQuery requires a window with a document at module.exports

Hi.
I try to get type definition of react-virtual-keyboard and virtual-keyboard libraries. They are installed.
Then I write dts-gen -m react-virtual-keyboard and get an error:

Error: jQuery requires a window with a document at module.exports (/.../.../node_modules/jquery/dist/jquery.js:31:12) at /.../.../node_modules/virtual-keyboard/dist/js/jquery.keyboard.js:2899:2 at $.keyboard.base (/.../.../node_modules/virtual-keyboard/dist/js/jquery.keyboard.js:36:20) at Object.<anonymous> (/.../.../node_modules/virtual-keyboard/dist/js/jquery.keyboard.js:40:2) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17)

What does it mean?

I tried to use var s = document.createElement('script'); s.src = 'https://unpkg.com/dts-gen/bin/browser-bundle.js'; document.body.appendChild(s); in browser, but it didn't help me. Perhaps, I did something wrong.

dts-gen, unexpected crash using Adal-Node module.

Ran into this today while trying to short-cut writing a typings file. It asked that I log a bug since it was an unexpected crash. If it can be resolved, awesome!

Tried using Windows 10, administrative Powershell and command prompt, both dts-gen and adal-node were loaded globally with npm install -g <module>.

C:\> dts-gen -m adal-node
Unexpected crash! Please log a bug with the commandline you specified.
dts-gen : C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:107
At line:1 char:1
+ dts-gen -m adal-node
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\<username>...\lib\run.js:107:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

        throw e;
        ^
TypeError: Cannot read property 'url' of undefined
    at AuthenticationContext.Object.defineProperty.get 
(C:\Users\<username>\AppData\Roaming\npm\node_modules\adal-node\lib\authentication-context.js:109:27)
    at C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:143
    at Array.map (native)
    at getClassPrototypeMembers (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:75)
    at getResult (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:138:17)
    at getTopLevelDeclarations (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at getResult (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:198:33)
    at getTopLevelDeclarations (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at Object.generateModuleDeclarationFile 
(C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:49:17)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:52:24)

Support operating on individual files

Maybe related to #14, but as people migrate their JavaScript to TypeScript and are looking for an easier process when --allowJs isn't picking up the slack, I think dts-gen can come in handy here.

CC @bowdenk7

unexpected crash -- message requested a bug

First thing I tried generated a crash::

npm install -g dts-gen
npm install -g antlr4
dts-gen -m antlr4

Versions:

[email protected]
[email protected]
node v6.3.1
npm v3.10.6

Results:

Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:107
        throw e;
        ^

TypeError: Cannot read property 'sourceName' of undefined
    at Lexer.sourceName (C:\Users\Burt_\AppData\Roaming\npm\node_modules\antlr4\Lexer.js:240:21)
    at C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:143
    at Array.map (native)
    at getClassPrototypeMembers (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:272:75)
    at getResult (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:138:17)
    at getTopLevelDeclarations (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at getResult (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:198:33)
    at getTopLevelDeclarations (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:126:15)
    at Object.generateModuleDeclarationFile (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:49:17)
    at Object.<anonymous> (C:\Users\Burt_\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:52:24)

How to generate .d.ts for ES6 Modules ?

(function (exports, require, module, __filename, __dirname) { 
  import {NativeModules, DeviceEventEmitter, Platform} from 'react-native';
                                                              ^^^^^^
SyntaxError: Unexpected token import

I have a third party library written in ES6, how could I generate typings for this ?

Unexpected crash -- ReferenceError: document is not defined

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

ReferenceError: document is not defined
    at Object.<anonymous> (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:2332:13)
    at __webpack_require__ (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:36:30)
    at Object.<anonymous> (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:1659:2)
    at __webpack_require__ (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:36:30)
    at Object.<anonymous> (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:76:15)
    at __webpack_require__ (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:36:30)
    at Object.defineProperty.value (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:7730:14)
    at __webpack_require__ (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:36:30)
    at Object.<anonymous> (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:63:19)
    at __webpack_require__ (/Users/eric/Code/foo/node_modules/quill/dist/quill.js:36:30)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.