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

Use TSAbstractFunctionExpression for abstract methods. #410

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions lib/ast-node-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ module.exports = {
* TS-prefixed nodes
*/
TSAbstractClassProperty: "TSAbstractClassProperty",
TSAbstractFunctionExpression: "TSAbstractFunctionExpression",
TSAbstractKeyword: "TSAbstractKeyword",
TSAbstractMethodDefinition: "TSAbstractMethodDefinition",
TSAnyKeyword: "TSAnyKeyword",
Expand Down
5 changes: 3 additions & 2 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,9 @@ module.exports = function convert(config) {

const methodLoc = ast.getLineAndCharacterOfPosition(openingParen.getStart()),
nodeIsMethod = (node.kind === SyntaxKind.MethodDeclaration),
isMethodAbstract = nodeUtils.hasModifier(SyntaxKind.AbstractKeyword, node),
method = {
type: AST_NODE_TYPES.FunctionExpression,
type: isMethodAbstract ? AST_NODE_TYPES.TSAbstractFunctionExpression : AST_NODE_TYPES.FunctionExpression,
id: null,
generator: !!node.asteriskToken,
expression: false,
Expand Down Expand Up @@ -913,7 +914,7 @@ module.exports = function convert(config) {
/**
* TypeScript class methods can be defined as "abstract"
*/
const methodDefinitionType = nodeUtils.hasModifier(SyntaxKind.AbstractKeyword, node)
const methodDefinitionType = isMethodAbstract
? AST_NODE_TYPES.TSAbstractMethodDefinition
: AST_NODE_TYPES.MethodDefinition;

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/__snapshots__/typescript.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ Object {
},
},
},
"type": "FunctionExpression",
"type": "TSAbstractFunctionExpression",
},
},
],
Expand Down