dart-archive / js_facade_gen

Generates package:js Javascript interop facades for arbitrary TypeScript libraries
Apache License 2.0
162 stars 29 forks source link

Type error when converting lodash #15

Closed sureshg closed 8 years ago

sureshg commented 8 years ago

TS type definiftion files used - lodash

$ node build/lib/main.js --destination=~/code/dart ~/code/DefinitelyTyped/lodash/lodash.d.ts
Transpiling [ '/Users/sgopal1/code/DefinitelyTyped/lodash/lodash.d.ts' ] to ~/code/dart
/Users/sgopal1/code/dart/js_facade_gen/build/lib/main.js:535
            throw e;
            ^

TypeError: Cannot read property 'text' of undefined
    at getErrorSpanForNode (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:5100:39)
    at Object.createDiagnosticForNode (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:5025:20)
    at error (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:15203:22)
    at getTypeFromClassOrInterfaceReference (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:19162:21)
    at getTypeFromTypeReference (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:19264:80)
    at getTypeFromTypeNode (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:19594:28)
    at Object.getTypeOfNode [as getTypeAtLocation] (/Users/sgopal1/code/dart/js_facade_gen/node_modules/typescript/lib/typescript.js:29896:24)
    at FacadeConverter.commonSupertype (/Users/sgopal1/code/dart/js_facade_gen/build/lib/facade_converter.js:778:64)
    at FacadeConverter.findCommonType (/Users/sgopal1/code/dart/js_facade_gen/build/lib/facade_converter.js:699:34)
    at MergedType.toSimpleTypeNode (/Users/sgopal1/code/dart/js_facade_gen/build/lib/merge.js:89:34)```
kevmoo commented 8 years ago

Please try installing via npm install -g dart_js_facade_gen and try again

You should be able to run dart_js_facade_gen as the entry point now

sureshg commented 8 years ago

@kevmoo yeah... installed successfully, but no output when converting the d.ts file.

$ npm install -g dart_js_facade_gen
~/install/nodejs/bin/dart_js_facade_gen -> ~/install/nodejs/lib/node_modules/dart_js_facade_gen/index.js
~/install/nodejs/lib
└── dart_js_facade_gen@0.0.2

$ dart_js_facade_gen ~/code/DefinitelyTyped/lodash/lodash.d.ts
<<<< No Output>>>>>
$ node -v
v6.8.0
$ npm -v
3.10.8
sureshg commented 8 years ago

After the update it's started working again, but still throwing TypeError for lodash

$ dart_js_facade_gen ~/code/DefinitelyTyped/lodash/lodash.d.ts
/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/index.js:11
  if (e.name !== 'DartFacadeError') throw e;
                                    ^

TypeError: Cannot read property 'text' of undefined
    at getErrorSpanForNode (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:5100:39)
    at Object.createDiagnosticForNode (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:5025:20)
    at error (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:15203:22)
    at getTypeFromClassOrInterfaceReference (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:19162:21)
    at getTypeFromTypeReference (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:19264:80)
    at getTypeFromTypeNode (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:19594:28)
    at Object.getTypeOfNode [as getTypeAtLocation] (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/node_modules/typescript/lib/typescript.js:29896:24)
    at FacadeConverter.commonSupertype (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/build/lib/facade_converter.js:765:64)
    at FacadeConverter.findCommonType (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/build/lib/facade_converter.js:686:34)
    at MergedType.toSimpleTypeNode (/Users/sgopal1/install/nodejs/lib/node_modules/dart_js_facade_gen/build/lib/merge.js:86:34)``` 
kevmoo commented 8 years ago

CC @jacob314

jacob314 commented 8 years ago

Fix out for review https://codereview.chromium.org/2434903002/

Let me know if you hit issues with any other libraries.

jacob314 commented 8 years ago

Landed fix and published dart_js_facade_gen@0.0.6 which fixes the issue.