From c6047c7a3d8cae1db877a2d12554bc1d973ddd92 Mon Sep 17 00:00:00 2001 From: Reyad Attiyat Date: Sun, 19 Feb 2017 16:58:33 -0600 Subject: [PATCH] Fix: Label abstract function expression nodes (fixes #80) In newer versions of TypeScript the FunctionExpression node contains a null body. This will cause some rules to fail as they expect FunctionExpression to have a body and is defined that way in the ESTree spec. --- lib/ast-converter.js | 2 +- .../basics/abstract-class-with-abstract-method.result.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ast-converter.js b/lib/ast-converter.js index b978b90..40fc4f2 100644 --- a/lib/ast-converter.js +++ b/lib/ast-converter.js @@ -868,7 +868,6 @@ module.exports = function(ast, extra) { // Declarations case SyntaxKind.FunctionDeclaration: - var functionDeclarationType = "FunctionDeclaration"; if (node.modifiers && node.modifiers.length) { var isDeclareFunction = node.modifiers.some(function(modifier) { @@ -1134,6 +1133,7 @@ module.exports = function(ast, extra) { }); if (isAbstractMethod) { methodDefinitionType = "TSAbstractMethodDefinition"; + method.type = "TSAbstractFunctionExpression"; } } diff --git a/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js b/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js index c476c03..d7f608e 100644 --- a/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js +++ b/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js @@ -89,7 +89,7 @@ module.exports = { "name": "createSocket" }, "value": { - "type": "FunctionExpression", + "type": "TSAbstractFunctionExpression", "id": null, "generator": false, "expression": false,