-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser support for
satisfies
operator
- Loading branch information
1 parent
a14a33d
commit 123815b
Showing
7 changed files
with
144 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/cast/satisfies-const-error/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x satisfies const |
38 changes: 38 additions & 0 deletions
38
packages/babel-parser/test/fixtures/typescript/cast/satisfies-const-error/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, | ||
"errors": [ | ||
"SyntaxError: Unexpected keyword 'const'. (1:12)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, | ||
"expression": { | ||
"type": "TSSatisfiesExpression", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, | ||
"expression": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSTypeReference", | ||
"start":12,"end":17,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":17,"index":17}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":12,"end":17,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":17,"index":17},"identifierName":"const"}, | ||
"name": "const" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/typescript/cast/satisfies/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x satisfies T; | ||
x < y satisfies boolean; // (x < y) satisfies boolean; |
76 changes: 76 additions & 0 deletions
76
packages/babel-parser/test/fixtures/typescript/cast/satisfies/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":54,"index":69}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":54,"index":69}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, | ||
"expression": { | ||
"type": "TSSatisfiesExpression", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":13,"index":13}}, | ||
"expression": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSTypeReference", | ||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":15,"end":39,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":24,"index":39}}, | ||
"expression": { | ||
"type": "TSSatisfiesExpression", | ||
"start":15,"end":38,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":23,"index":38}}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start":15,"end":20,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":5,"index":20}}, | ||
"left": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":1,"index":16},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"operator": "<", | ||
"right": { | ||
"type": "Identifier", | ||
"start":19,"end":20,"loc":{"start":{"line":2,"column":4,"index":19},"end":{"line":2,"column":5,"index":20},"identifierName":"y"}, | ||
"name": "y" | ||
} | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSBooleanKeyword", | ||
"start":31,"end":38,"loc":{"start":{"line":2,"column":16,"index":31},"end":{"line":2,"column":23,"index":38}} | ||
} | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " (x < y) satisfies boolean;", | ||
"start":40,"end":69,"loc":{"start":{"line":2,"column":25,"index":40},"end":{"line":2,"column":54,"index":69}} | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " (x < y) satisfies boolean;", | ||
"start":40,"end":69,"loc":{"start":{"line":2,"column":25,"index":40},"end":{"line":2,"column":54,"index":69}} | ||
} | ||
] | ||
} |