Skip to content

Commit 4107e23

Browse files
committed
Use TSAbstractFunctionExpression for abstract methods.
Fixes eslint#80.
1 parent b4d22e7 commit 4107e23

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/ast-node-types.js

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ module.exports = {
102102
* TS-prefixed nodes
103103
*/
104104
TSAbstractClassProperty: "TSAbstractClassProperty",
105+
TSAbstractFunctionExpression: "TSAbstractFunctionExpression",
105106
TSAbstractKeyword: "TSAbstractKeyword",
106107
TSAbstractMethodDefinition: "TSAbstractMethodDefinition",
107108
TSAnyKeyword: "TSAnyKeyword",

lib/convert.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,9 @@ module.exports = function convert(config) {
868868

869869
const methodLoc = ast.getLineAndCharacterOfPosition(openingParen.getStart()),
870870
nodeIsMethod = (node.kind === SyntaxKind.MethodDeclaration),
871+
isMethodAbstract = nodeUtils.hasModifier(SyntaxKind.AbstractKeyword, node),
871872
method = {
872-
type: AST_NODE_TYPES.FunctionExpression,
873+
type: isMethodAbstract ? AST_NODE_TYPES.TSAbstractFunctionExpression : AST_NODE_TYPES.FunctionExpression,
873874
id: null,
874875
generator: !!node.asteriskToken,
875876
expression: false,
@@ -913,7 +914,7 @@ module.exports = function convert(config) {
913914
/**
914915
* TypeScript class methods can be defined as "abstract"
915916
*/
916-
const methodDefinitionType = nodeUtils.hasModifier(SyntaxKind.AbstractKeyword, node)
917+
const methodDefinitionType = isMethodAbstract
917918
? AST_NODE_TYPES.TSAbstractMethodDefinition
918919
: AST_NODE_TYPES.MethodDefinition;
919920

tests/lib/__snapshots__/typescript.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ Object {
11791179
},
11801180
},
11811181
},
1182-
"type": "FunctionExpression",
1182+
"type": "TSAbstractFunctionExpression",
11831183
},
11841184
},
11851185
],

0 commit comments

Comments
 (0)