diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/fixture.ts new file mode 100644 index 000000000000..3151b42d808e --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/fixture.ts @@ -0,0 +1 @@ +a()++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..99d70fe0d336 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ call-expr TSESTree - Error 1`] = ` +"TSError +> 1 | a()++; + | ^^^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..28dbe5eb0cbe --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ call-expr Babel - Error 1`] = `[SyntaxError: Invalid left-hand side in postfix operation. (1:0)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..d78bd34c0e40 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/call-expr/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ call-expr Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/fixture.ts new file mode 100644 index 000000000000..f85efba66e65 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/fixture.ts @@ -0,0 +1 @@ +1++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..b865892e099c --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ literal TSESTree - Error 1`] = ` +"TSError +> 1 | 1++; + | ^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..fae8771457f6 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ literal Babel - Error 1`] = `[SyntaxError: Invalid left-hand side in postfix operation. (1:0)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..27b640e2a9b3 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/literal/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ literal Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/fixture.ts new file mode 100644 index 000000000000..8ca46af977de --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/fixture.ts @@ -0,0 +1 @@ +x?.y++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..11b7cfb86db7 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain TSESTree - Error 1`] = ` +"TSError +> 1 | x?.y++; + | ^^^^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..0b089f45210e --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain Babel - Error 1`] = `[SyntaxError: This experimental syntax requires enabling the parser plugin: "optionalChainingAssign". (1:0)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..c885159e6f5e --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/fixture.ts new file mode 100644 index 000000000000..a0b0600d9718 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/fixture.ts @@ -0,0 +1 @@ +x?.y.z++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..47124ed689b4 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain2 TSESTree - Error 1`] = ` +"TSError +> 1 | x?.y.z++; + | ^^^^^^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..75a24ee97f7b --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain2 Babel - Error 1`] = `[SyntaxError: This experimental syntax requires enabling the parser plugin: "optionalChainingAssign". (1:0)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..7738fc5cc034 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain2/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain2 Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/fixture.ts new file mode 100644 index 000000000000..b84ecd36d994 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/fixture.ts @@ -0,0 +1 @@ +x?.y().z++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..3e691a5c8dd5 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain3 TSESTree - Error 1`] = ` +"TSError +> 1 | x?.y().z++; + | ^^^^^^^^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..45fb7b64fd13 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain3 Babel - Error 1`] = `[SyntaxError: This experimental syntax requires enabling the parser plugin: "optionalChainingAssign". (1:0)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..4583f6dbbdd2 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/optional-chain3/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ optional-chain3 Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/fixture.ts new file mode 100644 index 000000000000..72bf8d5de4f2 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/fixture.ts @@ -0,0 +1 @@ +(a())++; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..9e304a2beb93 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ paren-expr TSESTree - Error 1`] = ` +"TSError +> 1 | (a())++; + | ^^^^^ Invalid left-hand side expression in unary operation + 2 |" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..d2b3aa8b891f --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ paren-expr Babel - Error 1`] = `[SyntaxError: Invalid left-hand side in postfix operation. (1:1)]`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..7c9eced86151 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/_error_/paren-expr/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression _error_ paren-expr Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/fixture.ts b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/fixture.ts new file mode 100644 index 000000000000..d9cd1cd35dd7 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/fixture.ts @@ -0,0 +1,15 @@ +class F { + #a; + + m() { + this.#a++; + this.m().a++; + this[1] = 1; + F++; + // prettier-ignore + (this.#a)++; + (this.#a)++; + (this.#a satisfies number)++; + (this.#a as number)++; + } +} diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-Babel-AST.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-Babel-AST.shot new file mode 100644 index 000000000000..5d282e70bed8 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-Babel-AST.shot @@ -0,0 +1,525 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment Babel - AST 1`] = ` +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: false, + key: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + static: false, + value: null, + + range: [12, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + MethodDefinition { + type: "MethodDefinition", + computed: false, + key: Identifier { + type: "Identifier", + name: "m", + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + kind: "method", + static: false, + value: FunctionExpression { + type: "FunctionExpression", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: [ + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + + range: [29, 36], + loc: { + start: { column: 4, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + operator: "++", + prefix: false, + + range: [29, 38], + loc: { + start: { column: 4, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + + range: [29, 39], + loc: { + start: { column: 4, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: CallExpression { + type: "CallExpression", + arguments: [], + callee: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + name: "m", + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + + range: [44, 50], + loc: { + start: { column: 4, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + optional: false, + + range: [44, 52], + loc: { + start: { column: 4, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + name: "a", + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + + range: [44, 54], + loc: { + start: { column: 4, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + operator: "++", + prefix: false, + + range: [44, 56], + loc: { + start: { column: 4, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + + range: [44, 57], + loc: { + start: { column: 4, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: AssignmentExpression { + type: "AssignmentExpression", + left: MemberExpression { + type: "MemberExpression", + computed: true, + object: ThisExpression { + type: "ThisExpression", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + optional: false, + property: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + + range: [62, 69], + loc: { + start: { column: 4, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + operator: "=", + right: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 73], + loc: { + start: { column: 4, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 74], + loc: { + start: { column: 4, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: Identifier { + type: "Identifier", + name: "F", + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + operator: "++", + prefix: false, + + range: [79, 82], + loc: { + start: { column: 4, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + + range: [79, 83], + loc: { + start: { column: 4, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + + range: [112, 119], + loc: { + start: { column: 5, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + operator: "++", + prefix: false, + + range: [111, 122], + loc: { + start: { column: 4, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + + range: [111, 123], + loc: { + start: { column: 4, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [129, 133], + loc: { + start: { column: 5, line: 11 }, + end: { column: 9, line: 11 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [134, 136], + loc: { + start: { column: 10, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + + range: [129, 136], + loc: { + start: { column: 5, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [147, 153], + loc: { + start: { column: 23, line: 11 }, + end: { column: 29, line: 11 }, + }, + }, + + range: [129, 153], + loc: { + start: { column: 5, line: 11 }, + end: { column: 29, line: 11 }, + }, + }, + operator: "++", + prefix: false, + + range: [128, 156], + loc: { + start: { column: 4, line: 11 }, + end: { column: 32, line: 11 }, + }, + }, + + range: [128, 157], + loc: { + start: { column: 4, line: 11 }, + end: { column: 33, line: 11 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSAsExpression { + type: "TSAsExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [163, 167], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [168, 170], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + + range: [163, 170], + loc: { + start: { column: 5, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [174, 180], + loc: { + start: { column: 16, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + + range: [163, 180], + loc: { + start: { column: 5, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + operator: "++", + prefix: false, + + range: [162, 183], + loc: { + start: { column: 4, line: 12 }, + end: { column: 25, line: 12 }, + }, + }, + + range: [162, 184], + loc: { + start: { column: 4, line: 12 }, + end: { column: 26, line: 12 }, + }, + }, + ], + + range: [23, 188], + loc: { + start: { column: 6, line: 4 }, + end: { column: 3, line: 13 }, + }, + }, + expression: false, + generator: false, + id: null, + params: [], + + range: [20, 188], + loc: { + start: { column: 3, line: 4 }, + end: { column: 3, line: 13 }, + }, + }, + + range: [19, 188], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 13 }, + }, + }, + ], + + range: [8, 190], + loc: { + start: { column: 8, line: 1 }, + end: { column: 1, line: 14 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + superClass: null, + + range: [0, 190], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 14 }, + }, + }, + ], + sourceType: "script", + + range: [0, 191], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 15 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..73ab33da2857 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,617 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment TSESTree - AST 1`] = ` +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: false, + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: false, + declare: false, + decorators: [], + definite: false, + key: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + optional: false, + override: false, + readonly: false, + static: false, + value: null, + + range: [12, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + MethodDefinition { + type: "MethodDefinition", + computed: false, + decorators: [], + key: Identifier { + type: "Identifier", + decorators: [], + name: "m", + optional: false, + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + kind: "method", + optional: false, + override: false, + static: false, + value: FunctionExpression { + type: "FunctionExpression", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: [ + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + + range: [29, 36], + loc: { + start: { column: 4, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + operator: "++", + prefix: false, + + range: [29, 38], + loc: { + start: { column: 4, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + + range: [29, 39], + loc: { + start: { column: 4, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: CallExpression { + type: "CallExpression", + arguments: [], + callee: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + decorators: [], + name: "m", + optional: false, + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + + range: [44, 50], + loc: { + start: { column: 4, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + optional: false, + + range: [44, 52], + loc: { + start: { column: 4, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + decorators: [], + name: "a", + optional: false, + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + + range: [44, 54], + loc: { + start: { column: 4, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + operator: "++", + prefix: false, + + range: [44, 56], + loc: { + start: { column: 4, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + + range: [44, 57], + loc: { + start: { column: 4, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: AssignmentExpression { + type: "AssignmentExpression", + left: MemberExpression { + type: "MemberExpression", + computed: true, + object: ThisExpression { + type: "ThisExpression", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + optional: false, + property: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + + range: [62, 69], + loc: { + start: { column: 4, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + operator: "=", + right: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 73], + loc: { + start: { column: 4, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 74], + loc: { + start: { column: 4, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: Identifier { + type: "Identifier", + decorators: [], + name: "F", + optional: false, + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + operator: "++", + prefix: false, + + range: [79, 82], + loc: { + start: { column: 4, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + + range: [79, 83], + loc: { + start: { column: 4, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + + range: [112, 119], + loc: { + start: { column: 5, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + operator: "++", + prefix: false, + + range: [111, 122], + loc: { + start: { column: 4, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + + range: [111, 123], + loc: { + start: { column: 4, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSTypeAssertion { + type: "TSTypeAssertion", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + + range: [137, 144], + loc: { + start: { column: 13, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + + range: [129, 144], + loc: { + start: { column: 5, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + operator: "++", + prefix: false, + + range: [128, 147], + loc: { + start: { column: 4, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + + range: [128, 148], + loc: { + start: { column: 4, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + + range: [154, 161], + loc: { + start: { column: 5, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + + range: [154, 178], + loc: { + start: { column: 5, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + operator: "++", + prefix: false, + + range: [153, 181], + loc: { + start: { column: 4, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + + range: [153, 182], + loc: { + start: { column: 4, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSAsExpression { + type: "TSAsExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + + range: [188, 195], + loc: { + start: { column: 5, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + + range: [188, 205], + loc: { + start: { column: 5, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + operator: "++", + prefix: false, + + range: [187, 208], + loc: { + start: { column: 4, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + + range: [187, 209], + loc: { + start: { column: 4, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + ], + + range: [23, 213], + loc: { + start: { column: 6, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + declare: false, + expression: false, + generator: false, + id: null, + params: [], + + range: [20, 213], + loc: { + start: { column: 3, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + + range: [19, 213], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + ], + + range: [8, 215], + loc: { + start: { column: 8, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, + declare: false, + decorators: [], + id: Identifier { + type: "Identifier", + decorators: [], + name: "F", + optional: false, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + implements: [], + superClass: null, + + range: [0, 215], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, + ], + sourceType: "script", + + range: [0, 216], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 16 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-Babel-Tokens.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-Babel-Tokens.shot new file mode 100644 index 000000000000..3431ef68783e --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-Babel-Tokens.shot @@ -0,0 +1,606 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment Babel - Tokens 1`] = ` +[ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [14, 15], + loc: { + start: { column: 4, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 3, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 4, line: 4 }, + end: { column: 5, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [23, 24], + loc: { + start: { column: 6, line: 4 }, + end: { column: 7, line: 4 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [33, 34], + loc: { + start: { column: 8, line: 5 }, + end: { column: 9, line: 5 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [36, 38], + loc: { + start: { column: 11, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 13, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [48, 49], + loc: { + start: { column: 8, line: 6 }, + end: { column: 9, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [50, 51], + loc: { + start: { column: 10, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [51, 52], + loc: { + start: { column: 11, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [52, 53], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [54, 56], + loc: { + start: { column: 14, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [56, 57], + loc: { + start: { column: 16, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [66, 67], + loc: { + start: { column: 8, line: 7 }, + end: { column: 9, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [68, 69], + loc: { + start: { column: 10, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [70, 71], + loc: { + start: { column: 12, line: 7 }, + end: { column: 13, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [73, 74], + loc: { + start: { column: 15, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [80, 82], + loc: { + start: { column: 5, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [82, 83], + loc: { + start: { column: 7, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [111, 112], + loc: { + start: { column: 4, line: 10 }, + end: { column: 5, line: 10 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [116, 117], + loc: { + start: { column: 9, line: 10 }, + end: { column: 10, line: 10 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [119, 120], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [120, 122], + loc: { + start: { column: 13, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [122, 123], + loc: { + start: { column: 15, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [128, 129], + loc: { + start: { column: 4, line: 11 }, + end: { column: 5, line: 11 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [129, 133], + loc: { + start: { column: 5, line: 11 }, + end: { column: 9, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [133, 134], + loc: { + start: { column: 9, line: 11 }, + end: { column: 10, line: 11 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [134, 136], + loc: { + start: { column: 10, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [137, 146], + loc: { + start: { column: 13, line: 11 }, + end: { column: 22, line: 11 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [147, 153], + loc: { + start: { column: 23, line: 11 }, + end: { column: 29, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [153, 154], + loc: { + start: { column: 29, line: 11 }, + end: { column: 30, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [154, 156], + loc: { + start: { column: 30, line: 11 }, + end: { column: 32, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [156, 157], + loc: { + start: { column: 32, line: 11 }, + end: { column: 33, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [162, 163], + loc: { + start: { column: 4, line: 12 }, + end: { column: 5, line: 12 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [163, 167], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [167, 168], + loc: { + start: { column: 9, line: 12 }, + end: { column: 10, line: 12 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [168, 170], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [171, 173], + loc: { + start: { column: 13, line: 12 }, + end: { column: 15, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [174, 180], + loc: { + start: { column: 16, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [180, 181], + loc: { + start: { column: 22, line: 12 }, + end: { column: 23, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [181, 183], + loc: { + start: { column: 23, line: 12 }, + end: { column: 25, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [183, 184], + loc: { + start: { column: 25, line: 12 }, + end: { column: 26, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [187, 188], + loc: { + start: { column: 2, line: 13 }, + end: { column: 3, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [189, 190], + loc: { + start: { column: 0, line: 14 }, + end: { column: 1, line: 14 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..88344ebebfee --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,706 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment TSESTree - Tokens 1`] = ` +[ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [14, 15], + loc: { + start: { column: 4, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 3, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 4, line: 4 }, + end: { column: 5, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [23, 24], + loc: { + start: { column: 6, line: 4 }, + end: { column: 7, line: 4 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [33, 34], + loc: { + start: { column: 8, line: 5 }, + end: { column: 9, line: 5 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [36, 38], + loc: { + start: { column: 11, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 13, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [48, 49], + loc: { + start: { column: 8, line: 6 }, + end: { column: 9, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [50, 51], + loc: { + start: { column: 10, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [51, 52], + loc: { + start: { column: 11, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [52, 53], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [54, 56], + loc: { + start: { column: 14, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [56, 57], + loc: { + start: { column: 16, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [66, 67], + loc: { + start: { column: 8, line: 7 }, + end: { column: 9, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [68, 69], + loc: { + start: { column: 10, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [70, 71], + loc: { + start: { column: 12, line: 7 }, + end: { column: 13, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [73, 74], + loc: { + start: { column: 15, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [80, 82], + loc: { + start: { column: 5, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [82, 83], + loc: { + start: { column: 7, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [111, 112], + loc: { + start: { column: 4, line: 10 }, + end: { column: 5, line: 10 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [116, 117], + loc: { + start: { column: 9, line: 10 }, + end: { column: 10, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [119, 120], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [120, 122], + loc: { + start: { column: 13, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [122, 123], + loc: { + start: { column: 15, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [128, 129], + loc: { + start: { column: 4, line: 11 }, + end: { column: 5, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [129, 130], + loc: { + start: { column: 5, line: 11 }, + end: { column: 6, line: 11 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [136, 137], + loc: { + start: { column: 12, line: 11 }, + end: { column: 13, line: 11 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [141, 142], + loc: { + start: { column: 17, line: 11 }, + end: { column: 18, line: 11 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [144, 145], + loc: { + start: { column: 20, line: 11 }, + end: { column: 21, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [145, 147], + loc: { + start: { column: 21, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [147, 148], + loc: { + start: { column: 23, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [153, 154], + loc: { + start: { column: 4, line: 12 }, + end: { column: 5, line: 12 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [158, 159], + loc: { + start: { column: 9, line: 12 }, + end: { column: 10, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [162, 171], + loc: { + start: { column: 13, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [178, 179], + loc: { + start: { column: 29, line: 12 }, + end: { column: 30, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [179, 181], + loc: { + start: { column: 30, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [181, 182], + loc: { + start: { column: 32, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [187, 188], + loc: { + start: { column: 4, line: 13 }, + end: { column: 5, line: 13 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [192, 193], + loc: { + start: { column: 9, line: 13 }, + end: { column: 10, line: 13 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [196, 198], + loc: { + start: { column: 13, line: 13 }, + end: { column: 15, line: 13 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [205, 206], + loc: { + start: { column: 22, line: 13 }, + end: { column: 23, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [206, 208], + loc: { + start: { column: 23, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [208, 209], + loc: { + start: { column: 25, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [212, 213], + loc: { + start: { column: 2, line: 14 }, + end: { column: 3, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [214, 215], + loc: { + start: { column: 0, line: 15 }, + end: { column: 1, line: 15 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..3bb1e5bb04e8 --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/3-Babel-AST.shot @@ -0,0 +1,593 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment Babel - AST 1`] = ` +Program { + type: "Program", + body: [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: [ + PropertyDefinition { + type: "PropertyDefinition", + computed: false, + key: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + static: false, + value: null, + + range: [12, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + MethodDefinition { + type: "MethodDefinition", + computed: false, + key: Identifier { + type: "Identifier", + name: "m", + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + kind: "method", + static: false, + value: FunctionExpression { + type: "FunctionExpression", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: [ + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + + range: [29, 36], + loc: { + start: { column: 4, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + operator: "++", + prefix: false, + + range: [29, 38], + loc: { + start: { column: 4, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + + range: [29, 39], + loc: { + start: { column: 4, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: CallExpression { + type: "CallExpression", + arguments: [], + callee: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + name: "m", + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + + range: [44, 50], + loc: { + start: { column: 4, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + optional: false, + + range: [44, 52], + loc: { + start: { column: 4, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: "Identifier", + name: "a", + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + + range: [44, 54], + loc: { + start: { column: 4, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + operator: "++", + prefix: false, + + range: [44, 56], + loc: { + start: { column: 4, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + + range: [44, 57], + loc: { + start: { column: 4, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: AssignmentExpression { + type: "AssignmentExpression", + left: MemberExpression { + type: "MemberExpression", + computed: true, + object: ThisExpression { + type: "ThisExpression", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + optional: false, + property: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + + range: [62, 69], + loc: { + start: { column: 4, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + operator: "=", + right: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 73], + loc: { + start: { column: 4, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 74], + loc: { + start: { column: 4, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: Identifier { + type: "Identifier", + name: "F", + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + operator: "++", + prefix: false, + + range: [79, 82], + loc: { + start: { column: 4, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + + range: [79, 83], + loc: { + start: { column: 4, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + + range: [112, 119], + loc: { + start: { column: 5, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + operator: "++", + prefix: false, + + range: [111, 122], + loc: { + start: { column: 4, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + + range: [111, 123], + loc: { + start: { column: 4, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSTypeAssertion { + type: "TSTypeAssertion", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + + range: [137, 144], + loc: { + start: { column: 13, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + + range: [129, 144], + loc: { + start: { column: 5, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + operator: "++", + prefix: false, + + range: [128, 147], + loc: { + start: { column: 4, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + + range: [128, 148], + loc: { + start: { column: 4, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + + range: [154, 161], + loc: { + start: { column: 5, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + + range: [154, 178], + loc: { + start: { column: 5, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + operator: "++", + prefix: false, + + range: [153, 181], + loc: { + start: { column: 4, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + + range: [153, 182], + loc: { + start: { column: 4, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSAsExpression { + type: "TSAsExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + + range: [188, 195], + loc: { + start: { column: 5, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + + range: [188, 205], + loc: { + start: { column: 5, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + operator: "++", + prefix: false, + + range: [187, 208], + loc: { + start: { column: 4, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + + range: [187, 209], + loc: { + start: { column: 4, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + ], + + range: [23, 213], + loc: { + start: { column: 6, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + expression: false, + generator: false, + id: null, + params: [], + + range: [20, 213], + loc: { + start: { column: 3, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + + range: [19, 213], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + ], + + range: [8, 215], + loc: { + start: { column: 8, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + superClass: null, + + range: [0, 215], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, + ], + sourceType: "script", + + range: [0, 216], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 16 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..6ac417a13b3f --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,706 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment Babel - Tokens 1`] = ` +[ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [14, 15], + loc: { + start: { column: 4, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 3, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 4, line: 4 }, + end: { column: 5, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [23, 24], + loc: { + start: { column: 6, line: 4 }, + end: { column: 7, line: 4 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [33, 34], + loc: { + start: { column: 8, line: 5 }, + end: { column: 9, line: 5 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [36, 38], + loc: { + start: { column: 11, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [38, 39], + loc: { + start: { column: 13, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [48, 49], + loc: { + start: { column: 8, line: 6 }, + end: { column: 9, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "m", + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [50, 51], + loc: { + start: { column: 10, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [51, 52], + loc: { + start: { column: 11, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [52, 53], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [54, 56], + loc: { + start: { column: 14, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [56, 57], + loc: { + start: { column: 16, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [66, 67], + loc: { + start: { column: 8, line: 7 }, + end: { column: 9, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [68, 69], + loc: { + start: { column: 10, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [70, 71], + loc: { + start: { column: 12, line: 7 }, + end: { column: 13, line: 7 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [73, 74], + loc: { + start: { column: 15, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [80, 82], + loc: { + start: { column: 5, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [82, 83], + loc: { + start: { column: 7, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [111, 112], + loc: { + start: { column: 4, line: 10 }, + end: { column: 5, line: 10 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [116, 117], + loc: { + start: { column: 9, line: 10 }, + end: { column: 10, line: 10 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [119, 120], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [120, 122], + loc: { + start: { column: 13, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [122, 123], + loc: { + start: { column: 15, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [128, 129], + loc: { + start: { column: 4, line: 11 }, + end: { column: 5, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [129, 130], + loc: { + start: { column: 5, line: 11 }, + end: { column: 6, line: 11 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [136, 137], + loc: { + start: { column: 12, line: 11 }, + end: { column: 13, line: 11 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [141, 142], + loc: { + start: { column: 17, line: 11 }, + end: { column: 18, line: 11 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [144, 145], + loc: { + start: { column: 20, line: 11 }, + end: { column: 21, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [145, 147], + loc: { + start: { column: 21, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [147, 148], + loc: { + start: { column: 23, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [153, 154], + loc: { + start: { column: 4, line: 12 }, + end: { column: 5, line: 12 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [158, 159], + loc: { + start: { column: 9, line: 12 }, + end: { column: 10, line: 12 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [162, 171], + loc: { + start: { column: 13, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [178, 179], + loc: { + start: { column: 29, line: 12 }, + end: { column: 30, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [179, 181], + loc: { + start: { column: 30, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [181, 182], + loc: { + start: { column: 32, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [187, 188], + loc: { + start: { column: 4, line: 13 }, + end: { column: 5, line: 13 }, + }, + }, + Keyword { + type: "Keyword", + value: "this", + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [192, 193], + loc: { + start: { column: 9, line: 13 }, + end: { column: 10, line: 13 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [196, 198], + loc: { + start: { column: 13, line: 13 }, + end: { column: 15, line: 13 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [205, 206], + loc: { + start: { column: 22, line: 13 }, + end: { column: 23, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [206, 208], + loc: { + start: { column: 23, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [208, 209], + loc: { + start: { column: 25, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [212, 213], + loc: { + start: { column: 2, line: 14 }, + end: { column: 3, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [214, 215], + loc: { + start: { column: 0, line: 15 }, + end: { column: 1, line: 15 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..ad036e5f596c --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,621 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', +- abstract: false, + body: ClassBody { + type: 'ClassBody', + body: Array [ + PropertyDefinition { + type: 'PropertyDefinition', + computed: false, +- declare: false, +- decorators: Array [], +- definite: false, + key: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, +- optional: false, +- override: false, +- readonly: false, + static: false, + value: null, + + range: [12, 15], + loc: { + start: { column: 2, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + MethodDefinition { + type: 'MethodDefinition', + computed: false, +- decorators: Array [], + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'm', +- optional: false, + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + kind: 'method', +- optional: false, +- override: false, + static: false, + value: FunctionExpression { + type: 'FunctionExpression', + async: false, + body: BlockStatement { + type: 'BlockStatement', + body: Array [ + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + + range: [29, 36], + loc: { + start: { column: 4, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + operator: '++', + prefix: false, + + range: [29, 38], + loc: { + start: { column: 4, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + + range: [29, 39], + loc: { + start: { column: 4, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: MemberExpression { + type: 'MemberExpression', + computed: false, + object: CallExpression { + type: 'CallExpression', + arguments: Array [], + callee: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'm', +- optional: false, + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + + range: [44, 50], + loc: { + start: { column: 4, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + optional: false, + + range: [44, 52], + loc: { + start: { column: 4, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + optional: false, + property: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'a', +- optional: false, + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + + range: [44, 54], + loc: { + start: { column: 4, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + operator: '++', + prefix: false, + + range: [44, 56], + loc: { + start: { column: 4, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + + range: [44, 57], + loc: { + start: { column: 4, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: AssignmentExpression { + type: 'AssignmentExpression', + left: MemberExpression { + type: 'MemberExpression', + computed: true, + object: ThisExpression { + type: 'ThisExpression', + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + optional: false, + property: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + + range: [62, 69], + loc: { + start: { column: 4, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + operator: '=', + right: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 73], + loc: { + start: { column: 4, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + + range: [62, 74], + loc: { + start: { column: 4, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'F', +- optional: false, + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + operator: '++', + prefix: false, + + range: [79, 82], + loc: { + start: { column: 4, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + + range: [79, 83], + loc: { + start: { column: 4, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + + range: [112, 119], + loc: { + start: { column: 5, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + operator: '++', + prefix: false, + + range: [111, 122], + loc: { + start: { column: 4, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + + range: [111, 123], + loc: { + start: { column: 4, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: TSTypeAssertion { + type: 'TSTypeAssertion', + expression: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + + range: [137, 144], + loc: { + start: { column: 13, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + + range: [129, 144], + loc: { + start: { column: 5, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + operator: '++', + prefix: false, + + range: [128, 147], + loc: { + start: { column: 4, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + + range: [128, 148], + loc: { + start: { column: 4, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: TSSatisfiesExpression { + type: 'TSSatisfiesExpression', + expression: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + + range: [154, 161], + loc: { + start: { column: 5, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + + range: [154, 178], + loc: { + start: { column: 5, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + operator: '++', + prefix: false, + + range: [153, 181], + loc: { + start: { column: 4, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + + range: [153, 182], + loc: { + start: { column: 4, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: TSAsExpression { + type: 'TSAsExpression', + expression: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + + range: [188, 195], + loc: { + start: { column: 5, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + + range: [188, 205], + loc: { + start: { column: 5, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + operator: '++', + prefix: false, + + range: [187, 208], + loc: { + start: { column: 4, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + + range: [187, 209], + loc: { + start: { column: 4, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + ], + + range: [23, 213], + loc: { + start: { column: 6, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, +- declare: false, + expression: false, + generator: false, + id: null, + params: Array [], + + range: [20, 213], + loc: { + start: { column: 3, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + + range: [19, 213], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 14 }, + }, + }, + ], + + range: [8, 215], + loc: { + start: { column: 8, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, +- declare: false, +- decorators: Array [], + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'F', +- optional: false, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, +- implements: Array [], + superClass: null, + + range: [0, 215], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 15 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 216], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 16 }, + }, + }" +`; diff --git a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..32f3ae8d058a --- /dev/null +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,728 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [12, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [14, 15], + loc: { + start: { column: 4, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'm', + + range: [19, 20], + loc: { + start: { column: 2, line: 4 }, + end: { column: 3, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [20, 21], + loc: { + start: { column: 3, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [21, 22], + loc: { + start: { column: 4, line: 4 }, + end: { column: 5, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [23, 24], + loc: { + start: { column: 6, line: 4 }, + end: { column: 7, line: 4 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [29, 33], + loc: { + start: { column: 4, line: 5 }, + end: { column: 8, line: 5 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [33, 34], + loc: { + start: { column: 8, line: 5 }, + end: { column: 9, line: 5 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [34, 36], + loc: { + start: { column: 9, line: 5 }, + end: { column: 11, line: 5 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [36, 38], + loc: { + start: { column: 11, line: 5 }, + end: { column: 13, line: 5 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [38, 39], + loc: { + start: { column: 13, line: 5 }, + end: { column: 14, line: 5 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [44, 48], + loc: { + start: { column: 4, line: 6 }, + end: { column: 8, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [48, 49], + loc: { + start: { column: 8, line: 6 }, + end: { column: 9, line: 6 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'm', + + range: [49, 50], + loc: { + start: { column: 9, line: 6 }, + end: { column: 10, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [50, 51], + loc: { + start: { column: 10, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [51, 52], + loc: { + start: { column: 11, line: 6 }, + end: { column: 12, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [52, 53], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'a', + + range: [53, 54], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [54, 56], + loc: { + start: { column: 14, line: 6 }, + end: { column: 16, line: 6 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [56, 57], + loc: { + start: { column: 16, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [62, 66], + loc: { + start: { column: 4, line: 7 }, + end: { column: 8, line: 7 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '[', + + range: [66, 67], + loc: { + start: { column: 8, line: 7 }, + end: { column: 9, line: 7 }, + }, + }, + Numeric { + type: 'Numeric', + value: '1', + + range: [67, 68], + loc: { + start: { column: 9, line: 7 }, + end: { column: 10, line: 7 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ']', + + range: [68, 69], + loc: { + start: { column: 10, line: 7 }, + end: { column: 11, line: 7 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [70, 71], + loc: { + start: { column: 12, line: 7 }, + end: { column: 13, line: 7 }, + }, + }, + Numeric { + type: 'Numeric', + value: '1', + + range: [72, 73], + loc: { + start: { column: 14, line: 7 }, + end: { column: 15, line: 7 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [73, 74], + loc: { + start: { column: 15, line: 7 }, + end: { column: 16, line: 7 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [79, 80], + loc: { + start: { column: 4, line: 8 }, + end: { column: 5, line: 8 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [80, 82], + loc: { + start: { column: 5, line: 8 }, + end: { column: 7, line: 8 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [82, 83], + loc: { + start: { column: 7, line: 8 }, + end: { column: 8, line: 8 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [111, 112], + loc: { + start: { column: 4, line: 10 }, + end: { column: 5, line: 10 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [112, 116], + loc: { + start: { column: 5, line: 10 }, + end: { column: 9, line: 10 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [116, 117], + loc: { + start: { column: 9, line: 10 }, + end: { column: 10, line: 10 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [117, 119], + loc: { + start: { column: 10, line: 10 }, + end: { column: 12, line: 10 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [119, 120], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [120, 122], + loc: { + start: { column: 13, line: 10 }, + end: { column: 15, line: 10 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [122, 123], + loc: { + start: { column: 15, line: 10 }, + end: { column: 16, line: 10 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [128, 129], + loc: { + start: { column: 4, line: 11 }, + end: { column: 5, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '<', + + range: [129, 130], + loc: { + start: { column: 5, line: 11 }, + end: { column: 6, line: 11 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'number', + + range: [130, 136], + loc: { + start: { column: 6, line: 11 }, + end: { column: 12, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '>', + + range: [136, 137], + loc: { + start: { column: 12, line: 11 }, + end: { column: 13, line: 11 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [137, 141], + loc: { + start: { column: 13, line: 11 }, + end: { column: 17, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [141, 142], + loc: { + start: { column: 17, line: 11 }, + end: { column: 18, line: 11 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [142, 144], + loc: { + start: { column: 18, line: 11 }, + end: { column: 20, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [144, 145], + loc: { + start: { column: 20, line: 11 }, + end: { column: 21, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [145, 147], + loc: { + start: { column: 21, line: 11 }, + end: { column: 23, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [147, 148], + loc: { + start: { column: 23, line: 11 }, + end: { column: 24, line: 11 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [153, 154], + loc: { + start: { column: 4, line: 12 }, + end: { column: 5, line: 12 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [154, 158], + loc: { + start: { column: 5, line: 12 }, + end: { column: 9, line: 12 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [158, 159], + loc: { + start: { column: 9, line: 12 }, + end: { column: 10, line: 12 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [159, 161], + loc: { + start: { column: 10, line: 12 }, + end: { column: 12, line: 12 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'satisfies', + + range: [162, 171], + loc: { + start: { column: 13, line: 12 }, + end: { column: 22, line: 12 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'number', + + range: [172, 178], + loc: { + start: { column: 23, line: 12 }, + end: { column: 29, line: 12 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [178, 179], + loc: { + start: { column: 29, line: 12 }, + end: { column: 30, line: 12 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [179, 181], + loc: { + start: { column: 30, line: 12 }, + end: { column: 32, line: 12 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [181, 182], + loc: { + start: { column: 32, line: 12 }, + end: { column: 33, line: 12 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [187, 188], + loc: { + start: { column: 4, line: 13 }, + end: { column: 5, line: 13 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [188, 192], + loc: { + start: { column: 5, line: 13 }, + end: { column: 9, line: 13 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [192, 193], + loc: { + start: { column: 9, line: 13 }, + end: { column: 10, line: 13 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [193, 195], + loc: { + start: { column: 10, line: 13 }, + end: { column: 12, line: 13 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'as', + + range: [196, 198], + loc: { + start: { column: 13, line: 13 }, + end: { column: 15, line: 13 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'number', + + range: [199, 205], + loc: { + start: { column: 16, line: 13 }, + end: { column: 22, line: 13 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [205, 206], + loc: { + start: { column: 22, line: 13 }, + end: { column: 23, line: 13 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [206, 208], + loc: { + start: { column: 23, line: 13 }, + end: { column: 25, line: 13 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [208, 209], + loc: { + start: { column: 25, line: 13 }, + end: { column: 26, line: 13 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [212, 213], + loc: { + start: { column: 2, line: 14 }, + end: { column: 3, line: 14 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [214, 215], + loc: { + start: { column: 0, line: 15 }, + end: { column: 1, line: 15 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index a41c223827df..409216445120 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -143,6 +143,7 @@ exports[`AST Fixtures List fixtures with AST differences 1`] = ` "expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/fixture.ts", "expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts", "expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/fixture.ts", + "expression/UpdateExpression/fixtures/valid-assignment/fixture.ts", "jsx/JSXNamespacedName/fixtures/component-dashed/fixture.tsx", "jsx/JSXNamespacedName/fixtures/component/fixture.tsx", "legacy-fixtures/accessor-decorators/fixtures/accessor-decorator-factory-instance-member/fixture.ts", diff --git a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot index b15734b809f0..43ef25b5170b 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -26,6 +26,7 @@ exports[`AST Fixtures List fixtures with Token differences 1`] = ` "element/AccessorProperty/fixtures/modifier-private/fixture.ts", "element/AccessorProperty/fixtures/modifier-protected/fixture.ts", "element/AccessorProperty/fixtures/modifier-public/fixture.ts", + "expression/UpdateExpression/fixtures/valid-assignment/fixture.ts", "jsx/JSXNamespacedName/fixtures/component-dashed/fixture.tsx", "jsx/JSXNamespacedName/fixtures/component/fixture.tsx", "legacy-fixtures/basics/fixtures/abstract-class-with-abstract-readonly-property/fixture.ts", diff --git a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts index 94c796a98a8e..ce3b72c06ad4 100644 --- a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts @@ -346,10 +346,6 @@ typeof (a); code: 'const x = !(1 as 1);', options: ['all', { nestedBinaryExpressions: false }], }, - { - code: 'const x = (1 as 1)++;', - options: ['all', { nestedBinaryExpressions: false }], - }, { code: 'function *x() { yield (1 as 1); yield 1; }', options: ['all', { nestedBinaryExpressions: false }], @@ -479,11 +475,6 @@ typeof (a); parserOptions: { ecmaFeatures: { jsx: false } }, options: ['all', { nestedBinaryExpressions: false }], }, - { - code: 'const x = (<1>1)++;', - parserOptions: { ecmaFeatures: { jsx: false } }, - options: ['all', { nestedBinaryExpressions: false }], - }, { code: 'function *x() { yield (<1>1); yield 1; }', parserOptions: { ecmaFeatures: { jsx: false } }, diff --git a/packages/eslint-plugin/tests/rules/no-unsafe-member-access.test.ts b/packages/eslint-plugin/tests/rules/no-unsafe-member-access.test.ts index 367ae0c6e3c2..292c52759c0d 100644 --- a/packages/eslint-plugin/tests/rules/no-unsafe-member-access.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unsafe-member-access.test.ts @@ -55,16 +55,6 @@ function foo(x: string[]) { } `, ` -function foo(x?: string[]) { - x?.[1++]; -} - `, - ` -function foo(x?: string[]) { - x?.[(1 as any)++]; -} - `, - ` class B implements FG.A {} `, ` diff --git a/packages/eslint-plugin/tests/rules/unbound-method.test.ts b/packages/eslint-plugin/tests/rules/unbound-method.test.ts index 9eb2b73b22c2..f0442c29cb03 100644 --- a/packages/eslint-plugin/tests/rules/unbound-method.test.ts +++ b/packages/eslint-plugin/tests/rules/unbound-method.test.ts @@ -207,8 +207,6 @@ function foo(instance: ContainsMethods | null) { instance?.bound(); instance?.unbound(); - instance?.bound++; - if (instance?.bound) { } if (instance?.unbound) { diff --git a/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts b/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts index 78e5e21bad5a..b9a07bf8181d 100644 --- a/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts +++ b/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts @@ -98,11 +98,6 @@ ruleTester.run('getWrappingFixer - voidEverythingRule', voidEverythingRule, { errors: [{ messageId: 'addVoid' }], output: '!(void wrapMe)', }, - { - code: 'wrapMe++', - errors: [{ messageId: 'addVoid' }], - output: '(void wrapMe)++', - }, { code: '"wrapMe" + "dontWrap"', errors: [{ messageId: 'addVoid' }], @@ -202,17 +197,6 @@ ruleTester.run('getWrappingFixer - voidEverythingRule', voidEverythingRule, { ;(void "wrapMe") + "!" `, }, - { - code: ` - dontWrap - wrapMe++ - `, - errors: [{ messageId: 'addVoid' }], - output: ` - dontWrap - ;(void wrapMe)++ - `, - }, { code: ` dontWrap() diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 5dcde889e8dd..7d7f394f6186 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -27,6 +27,7 @@ import { isESTreeClassMember, isOptional, isThisInTypeQuery, + isValidAssignmentTarget, nodeCanBeDecorated, nodeHasIllegalDecorators, nodeIsPresent, @@ -2021,6 +2022,12 @@ export class Converter { * ESTree uses UpdateExpression for ++/-- */ if (operator === '++' || operator === '--') { + if (!isValidAssignmentTarget(node.operand)) { + this.#throwUnlessAllowInvalidAST( + node.operand, + 'Invalid left-hand side expression in unary operation', + ); + } return this.createNode(node, { type: AST_NODE_TYPES.UpdateExpression, operator, diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index a131e8043e34..b3c4784a7fff 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -930,6 +930,33 @@ export function nodeCanBeDecorated(node: TSNode): boolean { return false; } +export function isValidAssignmentTarget(node: ts.Node): boolean { + switch (node.kind) { + case SyntaxKind.Identifier: + return true; + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + if (node.flags & ts.NodeFlags.OptionalChain) { + return false; + } + return true; + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.SatisfiesExpression: + return isValidAssignmentTarget( + ( + node as + | ts.ParenthesizedExpression + | ts.AssertionExpression + | ts.SatisfiesExpression + ).expression, + ); + default: + return false; + } +} + export function getNamespaceModifiers( node: ts.ModuleDeclaration, ): ts.Modifier[] | undefined {