Skip to content

Commit

Permalink
JS-307 Support TSSatisfiesExpression nodes (#4791)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-kebets-sonarsource authored Aug 30, 2024
1 parent ff9dfca commit 20ae576
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/jsts/src/parsers/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ function getProtobufShapeForNode(node: TSESTree.Node) {
case 'TSAsExpression':
// skipping node
return visitNode(node.expression);
case 'TSSatisfiesExpression':
// skipping node
return visitNode(node.expression);
case 'TSNonNullExpression':
// skipping node
return visitNode(node.expression);
Expand Down Expand Up @@ -362,7 +365,6 @@ function getProtobufShapeForNode(node: TSESTree.Node) {
case 'TSQualifiedName':
case 'TSReadonlyKeyword':
case 'TSRestType':
case 'TSSatisfiesExpression':
case 'TSStaticKeyword':
case 'TSStringKeyword':
case 'TSSymbolKeyword':
Expand Down
9 changes: 9 additions & 0 deletions packages/jsts/tests/parsers/ast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ describe('ast', () => {
).toEqual(NODE_TYPE_ENUM.values['LiteralType']); // Literal
});

test('should support TSSatisfiesExpression nodes', async () => {
const code = `42 satisfies Bar;`;
const ast = await parseSourceCode(code, parsers.typescript);
const serializedAST = visitNode(ast as TSESTree.Program);
const literalNode = serializedAST.program.body[0].expressionStatement.expression.literal;
expect(literalNode.type).toEqual(NODE_TYPE_ENUM.values['Literal']);
expect(literalNode.valueNumber).toEqual(42);
});

test('should support TSNonNullExpression nodes', async () => {
const code = `foo!;`;
const ast = await parseSourceCode(code, parsers.typescript);
Expand Down

0 comments on commit 20ae576

Please sign in to comment.