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 index d9cd1cd35dd7..95d8c6ce604f 100644 --- a/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/fixture.ts +++ b/packages/ast-spec/src/expression/UpdateExpression/fixtures/valid-assignment/fixture.ts @@ -11,5 +11,6 @@ class F { (this.#a)++; (this.#a satisfies number)++; (this.#a as number)++; + this.#a!++; } } 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 index 73ab33da2857..e3b3d53a23c1 100644 --- 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 @@ -547,12 +547,71 @@ Program { end: { column: 26, line: 13 }, }, }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSNonNullExpression { + type: "TSNonNullExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 221], + loc: { + start: { column: 4, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 222], + loc: { + start: { column: 4, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + operator: "++", + prefix: false, + + range: [214, 224], + loc: { + start: { column: 4, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + + range: [214, 225], + loc: { + start: { column: 4, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, ], - range: [23, 213], + range: [23, 229], loc: { start: { column: 6, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, declare: false, @@ -561,25 +620,25 @@ Program { id: null, params: [], - range: [20, 213], + range: [20, 229], loc: { start: { column: 3, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, - range: [19, 213], + range: [19, 229], loc: { start: { column: 2, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, ], - range: [8, 215], + range: [8, 231], loc: { start: { column: 8, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, declare: false, @@ -599,19 +658,19 @@ Program { implements: [], superClass: null, - range: [0, 215], + range: [0, 231], loc: { start: { column: 0, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, ], sourceType: "script", - range: [0, 216], + range: [0, 232], loc: { start: { column: 0, line: 1 }, - end: { column: 0, line: 16 }, + end: { column: 0, line: 17 }, }, } `; 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 index 88344ebebfee..61bd22e7480f 100644 --- 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 @@ -682,24 +682,84 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment TSESTree - To end: { column: 26, line: 13 }, }, }, + Keyword { + type: "Keyword", + value: "this", + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [218, 219], + loc: { + start: { column: 8, line: 14 }, + end: { column: 9, line: 14 }, + }, + }, + Identifier { + type: "Identifier", + value: "#a", + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "!", + + range: [221, 222], + loc: { + start: { column: 11, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [222, 224], + loc: { + start: { column: 12, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [224, 225], + loc: { + start: { column: 14, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, Punctuator { type: "Punctuator", value: "}", - range: [212, 213], + range: [228, 229], loc: { - start: { column: 2, line: 14 }, - end: { column: 3, line: 14 }, + start: { column: 2, line: 15 }, + end: { column: 3, line: 15 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [214, 215], + range: [230, 231], loc: { - start: { column: 0, line: 15 }, - end: { column: 1, line: 15 }, + start: { column: 0, line: 16 }, + end: { column: 1, line: 16 }, }, }, ] 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 index 3bb1e5bb04e8..00da94aaf270 100644 --- 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 @@ -529,12 +529,71 @@ Program { end: { column: 26, line: 13 }, }, }, + ExpressionStatement { + type: "ExpressionStatement", + expression: UpdateExpression { + type: "UpdateExpression", + argument: TSNonNullExpression { + type: "TSNonNullExpression", + expression: MemberExpression { + type: "MemberExpression", + computed: false, + object: ThisExpression { + type: "ThisExpression", + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: "PrivateIdentifier", + name: "a", + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 221], + loc: { + start: { column: 4, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 222], + loc: { + start: { column: 4, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + operator: "++", + prefix: false, + + range: [214, 224], + loc: { + start: { column: 4, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + + range: [214, 225], + loc: { + start: { column: 4, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, ], - range: [23, 213], + range: [23, 229], loc: { start: { column: 6, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, expression: false, @@ -542,25 +601,25 @@ Program { id: null, params: [], - range: [20, 213], + range: [20, 229], loc: { start: { column: 3, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, - range: [19, 213], + range: [19, 229], loc: { start: { column: 2, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, ], - range: [8, 215], + range: [8, 231], loc: { start: { column: 8, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, id: Identifier { @@ -575,19 +634,19 @@ Program { }, superClass: null, - range: [0, 215], + range: [0, 231], loc: { start: { column: 0, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, ], sourceType: "script", - range: [0, 216], + range: [0, 232], loc: { start: { column: 0, line: 1 }, - end: { column: 0, line: 16 }, + end: { column: 0, line: 17 }, }, } `; 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 index 6ac417a13b3f..738dbc31c358 100644 --- 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 @@ -682,24 +682,84 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment Babel - Token end: { column: 26, line: 13 }, }, }, + Keyword { + type: "Keyword", + value: "this", + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [218, 219], + loc: { + start: { column: 8, line: 14 }, + end: { column: 9, line: 14 }, + }, + }, + PrivateIdentifier { + type: "PrivateIdentifier", + value: "a", + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "!", + + range: [221, 222], + loc: { + start: { column: 11, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "++", + + range: [222, 224], + loc: { + start: { column: 12, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [224, 225], + loc: { + start: { column: 14, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, Punctuator { type: "Punctuator", value: "}", - range: [212, 213], + range: [228, 229], loc: { - start: { column: 2, line: 14 }, - end: { column: 3, line: 14 }, + start: { column: 2, line: 15 }, + end: { column: 3, line: 15 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [214, 215], + range: [230, 231], loc: { - start: { column: 0, line: 15 }, - end: { column: 1, line: 15 }, + start: { column: 0, line: 16 }, + end: { column: 1, line: 16 }, }, }, ] 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 index ad036e5f596c..5bef3a7c650f 100644 --- 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 @@ -551,12 +551,71 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment end: { column: 26, line: 13 }, }, }, + ExpressionStatement { + type: 'ExpressionStatement', + expression: UpdateExpression { + type: 'UpdateExpression', + argument: TSNonNullExpression { + type: 'TSNonNullExpression', + expression: MemberExpression { + type: 'MemberExpression', + computed: false, + object: ThisExpression { + type: 'ThisExpression', + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + optional: false, + property: PrivateIdentifier { + type: 'PrivateIdentifier', + name: 'a', + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 221], + loc: { + start: { column: 4, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + + range: [214, 222], + loc: { + start: { column: 4, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + operator: '++', + prefix: false, + + range: [214, 224], + loc: { + start: { column: 4, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + + range: [214, 225], + loc: { + start: { column: 4, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, ], - range: [23, 213], + range: [23, 229], loc: { start: { column: 6, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, - declare: false, @@ -565,25 +624,25 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment id: null, params: Array [], - range: [20, 213], + range: [20, 229], loc: { start: { column: 3, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, - range: [19, 213], + range: [19, 229], loc: { start: { column: 2, line: 4 }, - end: { column: 3, line: 14 }, + end: { column: 3, line: 15 }, }, }, ], - range: [8, 215], + range: [8, 231], loc: { start: { column: 8, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, - declare: false, @@ -603,19 +662,19 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment - implements: Array [], superClass: null, - range: [0, 215], + range: [0, 231], loc: { start: { column: 0, line: 1 }, - end: { column: 1, line: 15 }, + end: { column: 1, line: 16 }, }, }, ], sourceType: 'script', - range: [0, 216], + range: [0, 232], loc: { start: { column: 0, line: 1 }, - end: { column: 0, line: 16 }, + end: { column: 0, line: 17 }, }, }" `; 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 index 32f3ae8d058a..0ab0a542de73 100644 --- 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 @@ -704,24 +704,87 @@ exports[`AST Fixtures expression UpdateExpression valid-assignment AST Alignment end: { column: 26, line: 13 }, }, }, + Keyword { + type: 'Keyword', + value: 'this', + + range: [214, 218], + loc: { + start: { column: 4, line: 14 }, + end: { column: 8, line: 14 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '.', + + range: [218, 219], + loc: { + start: { column: 8, line: 14 }, + end: { column: 9, line: 14 }, + }, + }, +- Identifier { +- type: 'Identifier', +- value: '#a', ++ PrivateIdentifier { ++ type: 'PrivateIdentifier', ++ value: 'a', + + range: [219, 221], + loc: { + start: { column: 9, line: 14 }, + end: { column: 11, line: 14 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '!', + + range: [221, 222], + loc: { + start: { column: 11, line: 14 }, + end: { column: 12, line: 14 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '++', + + range: [222, 224], + loc: { + start: { column: 12, line: 14 }, + end: { column: 14, line: 14 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [224, 225], + loc: { + start: { column: 14, line: 14 }, + end: { column: 15, line: 14 }, + }, + }, Punctuator { type: 'Punctuator', value: '}', - range: [212, 213], + range: [228, 229], loc: { - start: { column: 2, line: 14 }, - end: { column: 3, line: 14 }, + start: { column: 2, line: 15 }, + end: { column: 3, line: 15 }, }, }, Punctuator { type: 'Punctuator', value: '}', - range: [214, 215], + range: [230, 231], loc: { - start: { column: 0, line: 15 }, - end: { column: 1, line: 15 }, + start: { column: 0, line: 16 }, + end: { column: 1, line: 16 }, }, }, ]" diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index b3c4784a7fff..8ff1c76ede25 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -944,12 +944,14 @@ export function isValidAssignmentTarget(node: ts.Node): boolean { case SyntaxKind.TypeAssertionExpression: case SyntaxKind.AsExpression: case SyntaxKind.SatisfiesExpression: + case SyntaxKind.NonNullExpression: return isValidAssignmentTarget( ( node as | ts.ParenthesizedExpression | ts.AssertionExpression | ts.SatisfiesExpression + | ts.NonNullExpression ).expression, ); default: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy