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

feat: support parsing satisfies operators #5717

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .prettierignore
Expand Up @@ -12,6 +12,9 @@ packages/eslint-plugin/src/configs/*.json
CONTRIBUTORS.md
packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts

# prettier doesn't yet support satisfies
packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/

# Ignore CHANGELOG.md files to avoid issues with automated release job
CHANGELOG.md

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -51,7 +51,7 @@ The latest version under the `canary` tag **(latest commit to `main`)** is:

### Supported TypeScript Version

**The version range of TypeScript currently supported by this parser is `>=3.3.1 <4.9.0`.**
**The version range of TypeScript currently supported by this parser is `>=3.3.1 <5.0.0`.**

These versions are what we test against.

Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -49,10 +49,11 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"devDependencies": {
"@babel/code-frame": "^7.16.7",
"@babel/eslint-parser": "^7.18.2",
"@babel/parser": "^7.18.0",
"@babel/types": "^7.18.2",
"@babel/code-frame": "^7.18.6",
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@babel/parser": "^7.20.3",
"@babel/types": "^7.20.2",
"@nrwl/nx-cloud": "14.7.0",
"@nrwl/workspace": "14.8.4",
"@swc/core": "^1.3.1",
Expand Down Expand Up @@ -109,7 +110,7 @@
"resolutions": {
"typescript": "~4.9.3",
"@types/node": "^18.11.9",
"//": "Pin jest to v29 across the repo",
"//": "Stub out unnecessary swc packages to improve install size and speed",
"@jest/create-cache-key-function": "^29",
"@jest/reporters": "^29",
"@jest/test-result": "^29",
Expand All @@ -121,7 +122,6 @@
"jest-snapshot": "^29",
"jest-util": "^29",
"pretty-format": "^29",
"//": "Stub out unnecessary swc packages to improve install size and speed",
"@swc/core-android-arm-eabi": "npm:dummypkg-a@1.0.0",
"@swc/core-android-arm64": "npm:dummypkg-a@1.0.0",
"@swc/core-freebsd-x64": "npm:dummypkg-a@1.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/ast-spec/src/ast-node-types.ts
Expand Up @@ -145,6 +145,7 @@ export enum AST_NODE_TYPES {
TSQualifiedName = 'TSQualifiedName',
TSReadonlyKeyword = 'TSReadonlyKeyword',
TSRestType = 'TSRestType',
TSSatisfiesExpression = 'TSSatisfiesExpression',
TSStaticKeyword = 'TSStaticKeyword',
TSStringKeyword = 'TSStringKeyword',
TSSymbolKeyword = 'TSSymbolKeyword',
Expand Down
@@ -0,0 +1 @@
[1,2,3] satisfies [1, 2, 3];
@@ -0,0 +1,149 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AST Fixtures expression TSSatisfiesExpression array-array TSESTree - AST 1`] = `
Program {
type: "Program",
body: Array [
ExpressionStatement {
type: "ExpressionStatement",
expression: TSSatisfiesExpression {
type: "TSSatisfiesExpression",
expression: ArrayExpression {
type: "ArrayExpression",
elements: Array [
Literal {
type: "Literal",
raw: "1",
value: 1,

range: [1, 2],
loc: {
start: { column: 1, line: 1 },
end: { column: 2, line: 1 },
},
},
Literal {
type: "Literal",
raw: "2",
value: 2,

range: [3, 4],
loc: {
start: { column: 3, line: 1 },
end: { column: 4, line: 1 },
},
},
Literal {
type: "Literal",
raw: "3",
value: 3,

range: [5, 6],
loc: {
start: { column: 5, line: 1 },
end: { column: 6, line: 1 },
},
},
],

range: [0, 7],
loc: {
start: { column: 0, line: 1 },
end: { column: 7, line: 1 },
},
},
typeAnnotation: TSTupleType {
type: "TSTupleType",
elementTypes: Array [
TSLiteralType {
type: "TSLiteralType",
literal: Literal {
type: "Literal",
raw: "1",
value: 1,

range: [19, 20],
loc: {
start: { column: 19, line: 1 },
end: { column: 20, line: 1 },
},
},

range: [19, 20],
loc: {
start: { column: 19, line: 1 },
end: { column: 20, line: 1 },
},
},
TSLiteralType {
type: "TSLiteralType",
literal: Literal {
type: "Literal",
raw: "2",
value: 2,

range: [22, 23],
loc: {
start: { column: 22, line: 1 },
end: { column: 23, line: 1 },
},
},

range: [22, 23],
loc: {
start: { column: 22, line: 1 },
end: { column: 23, line: 1 },
},
},
TSLiteralType {
type: "TSLiteralType",
literal: Literal {
type: "Literal",
raw: "3",
value: 3,

range: [25, 26],
loc: {
start: { column: 25, line: 1 },
end: { column: 26, line: 1 },
},
},

range: [25, 26],
loc: {
start: { column: 25, line: 1 },
end: { column: 26, line: 1 },
},
},
],

range: [18, 27],
loc: {
start: { column: 18, line: 1 },
end: { column: 27, line: 1 },
},
},

range: [0, 27],
loc: {
start: { column: 0, line: 1 },
end: { column: 27, line: 1 },
},
},

range: [0, 28],
loc: {
start: { column: 0, line: 1 },
end: { column: 28, line: 1 },
},
},
],
sourceType: "script",

range: [0, 29],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}
`;
@@ -0,0 +1,166 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AST Fixtures expression TSSatisfiesExpression array-array TSESTree - Tokens 1`] = `
Array [
Punctuator {
type: "Punctuator",
value: "[",

range: [0, 1],
loc: {
start: { column: 0, line: 1 },
end: { column: 1, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "1",

range: [1, 2],
loc: {
start: { column: 1, line: 1 },
end: { column: 2, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: ",",

range: [2, 3],
loc: {
start: { column: 2, line: 1 },
end: { column: 3, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "2",

range: [3, 4],
loc: {
start: { column: 3, line: 1 },
end: { column: 4, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: ",",

range: [4, 5],
loc: {
start: { column: 4, line: 1 },
end: { column: 5, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "3",

range: [5, 6],
loc: {
start: { column: 5, line: 1 },
end: { column: 6, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: "]",

range: [6, 7],
loc: {
start: { column: 6, line: 1 },
end: { column: 7, line: 1 },
},
},
Identifier {
type: "Identifier",
value: "satisfies",

range: [8, 17],
loc: {
start: { column: 8, line: 1 },
end: { column: 17, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: "[",

range: [18, 19],
loc: {
start: { column: 18, line: 1 },
end: { column: 19, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "1",

range: [19, 20],
loc: {
start: { column: 19, line: 1 },
end: { column: 20, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: ",",

range: [20, 21],
loc: {
start: { column: 20, line: 1 },
end: { column: 21, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "2",

range: [22, 23],
loc: {
start: { column: 22, line: 1 },
end: { column: 23, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: ",",

range: [23, 24],
loc: {
start: { column: 23, line: 1 },
end: { column: 24, line: 1 },
},
},
Numeric {
type: "Numeric",
value: "3",

range: [25, 26],
loc: {
start: { column: 25, line: 1 },
end: { column: 26, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: "]",

range: [26, 27],
loc: {
start: { column: 26, line: 1 },
end: { column: 27, line: 1 },
},
},
Punctuator {
type: "Punctuator",
value: ";",

range: [27, 28],
loc: {
start: { column: 27, line: 1 },
end: { column: 28, line: 1 },
},
},
]
`;