Git Product home page Git Product logo

tsd2cce's People

Contributors

eredo avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

tsd2cce's Issues

TypeError at parser.js:277

I'm trying to run this on (three.d.ts)[https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/threejs/three.d.ts] and getting:

$ /usr/local/lib/node_modules/tsd2cce/bin/tsd2cee three.d.ts x.js
/usr/local/lib/node_modules/tsd2cce/src/parser.js:277
        type[member.name.text] = {};
                        ^

TypeError: Cannot read property 'text' of undefined
    at /usr/local/lib/node_modules/tsd2cce/src/parser.js:277:25
    at Array.forEach (native)
    at Parser.transformType_ (/usr/local/lib/node_modules/tsd2cce/src/parser.js:276:25)
    at Parser.appendType_ (/usr/local/lib/node_modules/tsd2cce/src/parser.js:238:23)
    at /usr/local/lib/node_modules/tsd2cce/src/parser.js:299:19
    at Array.map (native)
    at Parser.getParameters_ (/usr/local/lib/node_modules/tsd2cce/src/parser.js:298:28)
    at Parser.defineMethod (/usr/local/lib/node_modules/tsd2cce/src/parser.js:368:12)
    at traverse (/usr/local/lib/node_modules/tsd2cce/src/parser.js:79:16)
    at visitEachNode (/usr/local/lib/node_modules/tsd2cce/node_modules/typescript/lib/typescript.js:7255:30)

I installed from NPM:

$ npm list -g tsd2cce 
/usr/local/lib
└── [email protected] 

Let me know if you need any other info!

Change the AST structure

The AST generated from the .d.ts file containing the closure types is not optimal. It's using an object map structure where properties are directly added into the object. Instead it should contain arrays for these properties.

Currently:

{
  qualifiedName: 'TestModule.TestClass',
  kind: NodeKind.CLASS
  staticMethod: {
    kind: NodeKind.FUNCTION,
    qualifiedName: 'TestModule.TestClass.staticMethod'
  },
  '#': {
    method: {
      kind: NodeKind.FUNCTION,
      qualifiedName: 'TestModule.TestClass.prototype.method'
    }
  }
}

Proposal:

{
  qualifiedName: 'TestModule.TestClass',
  kind: NodeKind.CLASS
  statics: [{
    name: 'staticMethod',
    kind: NodeKind.FUNCTION,
    qualifiedName: 'TestModule.TestClass.staticMethod'
  }],
  members: [{
    name: 'method',
    kind: NodeKind.FUNCTION,
    qualifiedName: 'TestModule.TestClass.prototype.method'
  }]
}

Executable called tsd2cee instead of tsd2cce and some errors under Windows

Hi,
I am curious for your tool in order to generate three.js externs.

There seems to be a typo in the installation routine as the command will be called tsd2cee instead of tsd2cce after installation.

But even with this in mind, I wasn´t able to run the tool.
I am getting this error:

C:\Users\xxxx\AppData\Roaming\npm\node_modules\tsd2cce\index.js:3
const Parser = require('./src/parser').Parser;
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    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 Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\rbu\AppData\Roaming\npm\node_modules\tsd2cce\bin\tsd2cee:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

and if I remove "use strict"; I get

C:\Users\xxxx\AppData\Roaming\npm\node_modules\tsd2cce\index.js:6
let argv = require('optimist')
    ^^^^
SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    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 Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\rbu\AppData\Roaming\npm\node_modules\tsd2cce\bin\tsd2cee:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

I apologize if this is a user error.

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.