eredo / tsd2cce Goto Github PK
View Code? Open in Web Editor NEWA converter which transforms typescript declaration files (.d.ts) to closure compiler externs.
License: MIT License
A converter which transforms typescript declaration files (.d.ts) to closure compiler externs.
License: MIT License
Add more test cases.
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.
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'
}]
}
Enums are currently just declared as objects.
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.