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

Releases/0.22.3 #1045

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ <h2><a id="docs"></a>Documentation</h2>

<h2><a id="releases"></a>Release history</h2>

<p class="release">13-09-2018: <a href="https://github.com/ternjs/tern/tree/0.22.2">Version 0.22.2</a></p>
<p class="release">27-09-2018: <a href="https://github.com/ternjs/tern/tree/0.22.3">Version 0.22.3</a></p>

<p class="release-note">Small update release that fixes crashes
affecting spread operator in object notation and rest operatore in object pattern.</p>
affecting spread operator in object notation, rest operatore in object pattern and export default anonymous class or function.</p>

<p class="release">28-08-2018: <a href="https://github.com/ternjs/tern/tree/0.22.0">Version 0.22</a></p>

Expand Down
21 changes: 18 additions & 3 deletions lib/infer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@
}
},
ClassDeclaration: function(node, scope, c) {
addVar(scope, node.id)
if (node.id) addVar(scope, node.id);
if (node.superClass) c(node.superClass, scope, "Expression")
for (var i = 0; i < node.body.body.length; i++)
c(node.body.body[i], scope)
Expand Down Expand Up @@ -1660,18 +1660,26 @@
infer(node, node.scope || scope, ANull);
},

ObjectExpression: function(node, scope) {
infer(node, node.scope || scope, ANull);
},

FunctionDeclaration: function(node, scope, c) {
var inner = node.scope, fn = inner.fnType;
connectParams(node, inner)
c(node.body, inner, "Statement");
maybeTagAsInstantiated(node, fn) || maybeTagAsGeneric(fn);
scope.getProp(node.id.name).addType(fn)
if (node.id) scope.getProp(node.id.name).addType(fn);
},

Statement: function(node, scope, c) {
c(node, node.scope || scope)
},

ExportDefaultDeclaration: function(node, scope, c) {
c(node.declaration, node.scope || scope)
},

VariableDeclaration: function(node, scope) {
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
Expand All @@ -1686,7 +1694,8 @@
},

ClassDeclaration: function(node, scope) {
scope.getProp(node.id.name).addType(inferClass(node, scope, node.id.name))
if (!node.id) inferClass(node, scope);
else scope.getProp(node.id.name).addType(inferClass(node, scope, node.id.name))
},

ReturnStatement: function(node, scope) {
Expand Down Expand Up @@ -1893,9 +1902,15 @@
ObjectExpression: function(node) {
return node.objType;
},
ClassDeclaration: function(node) {
return node.objType;
},
ClassExpression: function(node) {
return node.objType;
},
FunctionDeclaration: function(node) {
return node.scope.fnType;
},
FunctionExpression: function(node) {
return node.scope.fnType;
},
Expand Down
2 changes: 1 addition & 1 deletion lib/tern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,5 +1149,5 @@
return {files: srv.files.map(function(f){return f.name;})};
}

exports.version = "0.22.2";
exports.version = "0.22.3";
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tern",
"license": "MIT",
"version": "0.22.2",
"version": "0.22.3",
"author": "Marijn Haverbeke <[email protected]>",
"description": "A JavaScript code analyzer for deep, cross-editor language support",
"main": "lib/tern.js",
Expand Down
6 changes: 3 additions & 3 deletions plugin/es_modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
outObj.originNode = file.ast
out.addType(outObj)
}
var prop = outObj.defProp(prop, originNode)
prop.origin = file.name
type.propagate(prop)
var propObj = outObj.defProp(prop, originNode)
propObj.origin = file.name
type.propagate(propObj)
}

walk.simple(file.ast, {
Expand Down
4 changes: 4 additions & 0 deletions test/cases/es_modules/class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default class {
methodA() {
}
};
1 change: 1 addition & 0 deletions test/cases/es_modules/func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function () { return true; }
13 changes: 13 additions & 0 deletions test/cases/es_modules/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ import * as reexp from "./reexp"
reexp //:: {a: number, b: bool}

import "./b" //+ "./blah"

import C from "./class"

(new C()). //+ methodA

import f from "./func"

f //: fn() -> bool

import o from "./obj"

o.propA //: number
o.propB //: string
1 change: 1 addition & 0 deletions test/cases/es_modules/obj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {propA: 1, propB: "str"}