Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union type between a callback and another type is broken in a definition #733

Closed
fflorent opened this issue Mar 25, 2016 · 2 comments
Closed

Comments

@fflorent
Copy link

TernJS version : 0.18.0

STR:

  1. Open defs/ecma5.json
  2. Change Object.getPrototypeOf so that : "!type": "fn(obj: ?) -> ?|string (well, that's stupid, but that's just for having simple reproducible steps :))
  3. Run ternjs in a context where ecma5 is on

Actual result:

TernJS crashes with this stack trace :

/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/def.js:249
    if (/^fn\(/.test(spec)) for (var i = 0; i < type.args.length; ++i) (function(i) {
                                                         ^

TypeError: Cannot read property 'length' of undefined
    at parseType (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/def.js:249:
58)
    at passTwo (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/def.js:415:9)
    at passTwo (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/def.js:433:11
)
    at doLoadEnvironment (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/def
.js:475:5)
    at Object.exports.load (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/d
ef.js:487:7)
    at /home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/infer.js:858:13
    at Object.exports.withContext (/home/florent/.vim/bundle/tern_for_vim/node_modules/ter
n/lib/infer.js:872:18)
    at new exports.Context (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib/i
nfer.js:840:13)
    at Object.signal.mixin.reset (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern
/lib/tern.js:146:17)
    at Object.exports.Server (/home/florent/.vim/bundle/tern_for_vim/node_modules/tern/lib
/tern.js:126:10)

Context

I am trying to make extjs_5.0.0 plugin of the tern.jsduck project (ping @angelozerr) and some ExtJS properties (like this one) can accept both a function or a string.

Florent

@angelozerr
Copy link
Contributor

@fflorent hat's very cool! Any contribtution are welcome for https://github.com/angelozerr/tern.jsduck Thanks!

fflorent added a commit to fflorent/tern that referenced this issue Mar 25, 2016
fflorent added a commit to fflorent/tern that referenced this issue Mar 25, 2016
@fflorent
Copy link
Author

PR #734 submitted

@fflorent hat's very cool! Any contribtution are welcome for https://github.com/angelozerr/tern.jsduck Thanks!

Sure. With the above patch and minor changes to the generated definition, I could manage completion to work basically.
I plan to eventually make configuration / properties autocompletion work with Ext.define / Ext.create (taking into account the inheritance). I may need some hints later :).

Florent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants