Describe the bug
Version: 1.3.0
ts-morph throws errors syntax on ObjectBindingPattern and ArrayBindingPattern.
Not implemented feature for syntax kind 'ObjectBindingPattern'. [39m
Error: Not implemented feature for syntax kind 'ObjectBindingPattern'.
at NotImplementedError.BaseError [as constructor] (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/errors/classes/BaseError.js:8:28)
at new NotImplementedError (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/errors/classes/NotImplementedError.js:10:23)
at Object.getNotImplementedForSyntaxKindError (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/errors/helpers.js:79:12)
at ParameterDeclaration.DeclarationNamedNodeInternal.class_1.getNameNode (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/base/name/DeclarationNamedNode.js:35:34)
at ParameterDeclaration.DeclarationNamedNodeInternal.class_1.getName (/home/ITRANSITION.CORP/d.semigradsky/.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/base/name/DeclarationNamedNode.js:42:33)
at ParameterDeclaration.DeclarationNamedNodeInternal.class_1.getStructure (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/base/name/DeclarationNamedNode.js:57:28)
at Object.callBaseGetStructure (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/callBaseGetStructure.js:9:51)
at ParameterDeclaration.InitializerSetExpressionableNode.class_1.getStructure (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/base/initializer/InitializerSetExpressionableNode.js:50:43)
at Object.callBaseGetStructure (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/callBaseGetStructure.js:9:51)
at ParameterDeclaration.TypedNode.class_1.getStructure (/home/.../.npm/_npx/8522/lib/node_modules/arkit/node_modules/ts-morph/dist/compiler/ast/base/TypedNode.js:85:43
To Reproduce
The bug was reported in my project, I've requested some code samples: https://github.com/dyatko/arkit/issues/49
Expected behaviour
The syntax patterns handled properly.
@dyatko I fixed this a few days ago and it will be available in v2.0 (not sure when I'll release that... hopefully this weekend or next). In 2.0, when calling .getName() it will always return the name node's text even if it's an array binding pattern or object binding pattern.
A temporary workaround is to not use .getName() and instead do:
node.getNameNode().getText()
Oh, by the way, if you need to handle array binding patterns or object binding patterns in names (ex. function f([a], {b}) {}) then you might not want to get the text. In that case, you should handle them specifically by using type guards:
const nameNode = node.getNameNode();
if (TypeGuards.isObjectBindingPattern(nameNode)) {
// ...logic to handle object binding pattern here...
}
else if (TypeGuards.isArrayBindingPattern(nameNode)) {
// ...etc...
}
else {
console.log(nameNode.getText()); // should be an identifier here (going off my memory though)
}
@dsherret Great, thank you!