Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS-307 Support TSSatisfiesExpression nodes #4791

Merged
merged 2 commits into from
Aug 30, 2024
Merged
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
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