Reputation: 11
I would like to represent the typescript code "MyObj instanceOf MyClass" with the typescript compiler API.
I try to use the createBinary
API as follow:
ts.createBinary(leftExpression,ts.SyntaxKind.InstanceOfKeyword, rightExpression);
How do I create the rightExpression
?
Upvotes: 1
Views: 172
Reputation: 106640
The left and right expressions are identifiers, so the createIdentifier
method could be used:
const binaryExpression = ts.createBinary(ts.createIdentifier("MyObj"),
ts.SyntaxKind.InstanceOfKeyword,
ts.createIdentifier("MyClass"));
Upvotes: 1