This commit is contained in:
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/as-expression/input.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/as-expression/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(x as number) += 1;
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/as-expression/output.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/as-expression/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x += 1;
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/non-null/input.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/non-null/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x! += 1;
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/non-null/output.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/non-null/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x += 1;
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/type-assertion/input.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/type-assertion/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(<number> x) += 1;
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/type-assertion/output.js
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/lvalues/type-assertion/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x += 1;
|
||||
@@ -1941,6 +1941,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
case "TSParameterProperty":
|
||||
return super.toAssignable(node, isBinding, contextDescription);
|
||||
case "TSAsExpression":
|
||||
case "TSNonNullExpression":
|
||||
case "TSTypeAssertion":
|
||||
node.expression = this.toAssignable(
|
||||
node.expression,
|
||||
isBinding,
|
||||
@@ -1973,6 +1975,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
return;
|
||||
case "TSAsExpression":
|
||||
case "TSNonNullExpression":
|
||||
case "TSTypeAssertion":
|
||||
this.checkLVal(
|
||||
expr.expression,
|
||||
isBinding,
|
||||
|
||||
1
packages/babylon/test/fixtures/typescript/cast/null-assertion-and-assign/input.js
vendored
Normal file
1
packages/babylon/test/fixtures/typescript/cast/null-assertion-and-assign/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x! += 1;
|
||||
117
packages/babylon/test/fixtures/typescript/cast/null-assertion-and-assign/output.json
vendored
Normal file
117
packages/babylon/test/fixtures/typescript/cast/null-assertion-and-assign/output.json
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start": 0,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"operator": "+=",
|
||||
"left": {
|
||||
"type": "TSNonNullExpression",
|
||||
"start": 0,
|
||||
"end": 2,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 0,
|
||||
"end": 1,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babylon/test/fixtures/typescript/cast/type-assertion-and-assign/input.js
vendored
Normal file
1
packages/babylon/test/fixtures/typescript/cast/type-assertion-and-assign/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(<number> x) += 1;
|
||||
136
packages/babylon/test/fixtures/typescript/cast/type-assertion-and-assign/output.json
vendored
Normal file
136
packages/babylon/test/fixtures/typescript/cast/type-assertion-and-assign/output.json
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"operator": "+=",
|
||||
"left": {
|
||||
"type": "TSTypeAssertion",
|
||||
"start": 2,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start": 2,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 16,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user