Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiosantoscode/1ca94c66c9823a2d3331 to your computer and use it in GitHub Desktop.
Save fabiosantoscode/1ca94c66c9823a2d3331 to your computer and use it in GitHub Desktop.
fabio@thinkpadlel ♥ node
> var infer = require('tern/lib/infer')
> infer.parse
[Function]
> var parsed = infer.parse('var x=[1,2,3]')
undefined
> var ctx = new infer.Context()
undefined
> var nodeState; infer.withContext(ctx, () => { nodeState = infer.expressionType({ node: parsed.body[0].declarations[0].init, state: ctx.topScope }) })
undefined
> nodeState
{ props:
{ '<i>':
{ types: [Object],
forward: null,
maxWeight: 100,
propertyOf: [Circular],
propertyName: '<i>',
originNode: undefined,
origin: null } },
proto:
{ props: {},
proto:
{ props: {},
proto: null,
name: 'Object.prototype',
maybeProps: null,
origin: 'ecma5' },
name: 'Array.prototype',
maybeProps: null,
origin: 'ecma5' },
name: 'Array',
maybeProps: null,
origin: null,
tuple: 0 }
>
(To exit, press ^C again or type .exit)
>
fabio@thinkpadlel ♥
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment