Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.

Commit 43ef7c8

Browse files
committed
Correctly put typeParameters on FunctionExpression (#585)
1 parent 40f9a95 commit 43ef7c8

3 files changed

Lines changed: 413 additions & 6 deletions

File tree

src/plugins/estree.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ export default function (instance) {
152152
};
153153
});
154154

155-
instance.extend("parseClassMethod", function (inner) {
156-
return function (classBody, ...args) {
157-
inner.call(this, classBody, ...args);
158-
159-
const body = classBody.body;
160-
body[body.length - 1].type = "MethodDefinition";
155+
instance.extend("parseClassMethod", function () {
156+
return function (classBody, method, isGenerator, isAsync) {
157+
this.parseMethod(method, isGenerator, isAsync);
158+
if (method.typeParameters) {
159+
method.value.typeParameters = method.typeParameters;
160+
delete method.typeParameters;
161+
}
162+
classBody.body.push(this.finishNode(method, "MethodDefinition"));
161163
};
162164
});
163165

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class NodeUtils extends UtilParser {
2+
finishNodeAt<T : NodeType>(node: T): T {
3+
return node;
4+
}
5+
}

0 commit comments

Comments
 (0)