Update baselines, fix assignment check for object rest.
This commit is contained in:
parent
45772270a4
commit
60d5195112
|
@ -640,7 +640,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
|
|||
|
||||
// Local target to build the compiler and services
|
||||
var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false, { noMapRoot: true });
|
||||
|
||||
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
||||
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
|
||||
|
|
|
@ -3081,7 +3081,7 @@ namespace ts {
|
|||
}
|
||||
const literalMembers: PropertyName[] = [];
|
||||
for (const element of pattern.elements) {
|
||||
if (element.kind !== SyntaxKind.OmittedExpression && !(element as BindingElement).dotDotDotToken) {
|
||||
if (!(element as BindingElement).dotDotDotToken) {
|
||||
literalMembers.push(element.propertyName || element.name as Identifier);
|
||||
}
|
||||
}
|
||||
|
@ -14199,9 +14199,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else if (property.kind === SyntaxKind.SpreadAssignment) {
|
||||
if (property.expression.kind !== SyntaxKind.Identifier) {
|
||||
error(property.expression, Diagnostics.An_object_rest_element_must_be_an_identifier);
|
||||
}
|
||||
checkReferenceExpression(property.expression, Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access);
|
||||
}
|
||||
else {
|
||||
error(property, Diagnostics.Property_assignment_expected);
|
||||
|
|
|
@ -1991,7 +1991,7 @@
|
|||
"category": "Error",
|
||||
"code": 2700
|
||||
},
|
||||
"An object rest element must be an identifier.": {
|
||||
"The target of an object rest assignment must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2701
|
||||
},
|
||||
|
|
|
@ -3284,9 +3284,9 @@ namespace ts {
|
|||
return bindingElement.right;
|
||||
}
|
||||
|
||||
if (isSpreadExpression(bindingElement) && isBindingOrAssignmentElement(bindingElement.expression)) {
|
||||
if (isSpreadExpression(bindingElement)) {
|
||||
// Recovery consistent with existing emit.
|
||||
return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
|
||||
return getInitializerOfBindingOrAssignmentElement(<BindingOrAssignmentElement>bindingElement.expression);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3327,9 +3327,7 @@ namespace ts {
|
|||
// `b.c` in `({ a: b.c = 1 } = ...)`
|
||||
// `b[0]` in `({ a: b[0] } = ...)`
|
||||
// `b[0]` in `({ a: b[0] = 1 } = ...)`
|
||||
return isBindingOrAssignmentElement(bindingElement.initializer)
|
||||
? getTargetOfBindingOrAssignmentElement(bindingElement.initializer)
|
||||
: undefined;
|
||||
return getTargetOfBindingOrAssignmentElement(<BindingOrAssignmentElement>bindingElement.initializer);
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
// `a` in `({ a } = ...)`
|
||||
|
@ -3338,9 +3336,7 @@ namespace ts {
|
|||
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
// `a` in `({ ...a } = ...)`
|
||||
return isBindingOrAssignmentElement(bindingElement.expression)
|
||||
? getTargetOfBindingOrAssignmentElement(bindingElement.expression)
|
||||
: undefined;
|
||||
return getTargetOfBindingOrAssignmentElement(<BindingOrAssignmentElement>bindingElement.expression);
|
||||
}
|
||||
|
||||
// no target
|
||||
|
@ -3353,16 +3349,12 @@ namespace ts {
|
|||
// `[a]` in `[[a] = 1] = ...`
|
||||
// `a.b` in `[a.b = 1] = ...`
|
||||
// `a[0]` in `[a[0] = 1] = ...`
|
||||
return isBindingOrAssignmentElement(bindingElement.left)
|
||||
? getTargetOfBindingOrAssignmentElement(bindingElement.left)
|
||||
: undefined;
|
||||
return getTargetOfBindingOrAssignmentElement(<BindingOrAssignmentElement>bindingElement.left);
|
||||
}
|
||||
|
||||
if (isSpreadExpression(bindingElement)) {
|
||||
// `a` in `[...a] = ...`
|
||||
return isBindingOrAssignmentElement(bindingElement.expression)
|
||||
? getTargetOfBindingOrAssignmentElement(bindingElement.expression)
|
||||
: undefined;
|
||||
return getTargetOfBindingOrAssignmentElement(<BindingOrAssignmentElement>bindingElement.expression);
|
||||
}
|
||||
|
||||
// `a` in `[a] = ...`
|
||||
|
@ -3442,18 +3434,14 @@ namespace ts {
|
|||
case SyntaxKind.ArrayLiteralExpression:
|
||||
// `a` in `{a}`
|
||||
// `a` in `[a]`
|
||||
return map(name.elements, convertToBindingOrAssignmentElement);
|
||||
return <BindingOrAssignmentElement[]>name.elements;
|
||||
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
// `a` in `{a}`
|
||||
return filter(name.properties, isBindingOrAssignmentElement);
|
||||
return <BindingOrAssignmentElement[]>name.properties;
|
||||
}
|
||||
}
|
||||
|
||||
function convertToBindingOrAssignmentElement(node: Node) {
|
||||
return isBindingOrAssignmentElement(node) ? node : createOmittedExpression(node);
|
||||
}
|
||||
|
||||
export function convertToArrayAssignmentElement(element: BindingOrAssignmentElement) {
|
||||
if (isBindingElement(element)) {
|
||||
if (element.dotDotDotToken) {
|
||||
|
|
|
@ -292,6 +292,10 @@ namespace ts {
|
|||
// can perform the ObjectRest destructuring in a different declaration
|
||||
if (element.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
const temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
if (!host.recordTempVariablesInLine) {
|
||||
host.context.hoistVariableDeclaration(temp);
|
||||
}
|
||||
|
||||
restContainingElements = append(restContainingElements, <[Identifier, BindingOrAssignmentElement]>[temp, element]);
|
||||
bindingElements = append(bindingElements, host.createArrayBindingOrAssignmentElement(temp));
|
||||
}
|
||||
|
|
|
@ -734,7 +734,7 @@ namespace ts {
|
|||
elements: NodeArray<ArrayBindingElement>;
|
||||
}
|
||||
|
||||
export type BindingPattern = (ObjectBindingPattern | ArrayBindingPattern) & { elements: NodeArray<ArrayBindingElement>; };
|
||||
export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern;
|
||||
|
||||
export type ArrayBindingElement = BindingElement | OmittedExpression;
|
||||
|
||||
|
|
|
@ -3975,29 +3975,6 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a node is a BindingOrAssignmentElement
|
||||
*/
|
||||
export function isBindingOrAssignmentElement(node: Node): node is BindingOrAssignmentElement {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.SpreadElement:
|
||||
return true;
|
||||
}
|
||||
return isAssignmentExpression(node, /*excludeCompoundAssignment*/ true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a node is a BindingOrAssignmentPattern
|
||||
*/
|
||||
|
|
|
@ -61,6 +61,10 @@ function createRunner(kind: TestRunnerKind): RunnerBase {
|
|||
}
|
||||
}
|
||||
|
||||
if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.getEnvironmentVariable("NODE_ENV"))) {
|
||||
Harness.IO.tryEnableSourceMapsForHost();
|
||||
}
|
||||
|
||||
// users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options
|
||||
|
||||
const mytestconfigFileName = "mytest.config";
|
||||
|
|
|
@ -30,6 +30,6 @@ let complex;
|
|||
// should be:
|
||||
let overEmit;
|
||||
// var _g = overEmit.a, [_h, ...y] = _g, nested2 = __rest(_h, []), _j = overEmit.b, { z } = _j, c = __rest(_j, ["z"]), rest2 = __rest(overEmit, ["a", "b"]);
|
||||
var _b = overEmit.a, [_c, ...y] = _b, nested2 = __rest(_c, []), _d = overEmit.b, { z } = _d, c = __rest(_d, ["z"]), rest2 = __rest(overEmit, ["a", "b"]);
|
||||
(_e = overEmit.a, [_f, ...y] = _e, nested2 = __rest(_f, []), _g = overEmit.b, { z } = _g, c = __rest(_g, ["z"]), rest2 = __rest(overEmit, ["a", "b"]));
|
||||
var _a, _e, _g;
|
||||
var [_b, ...y] = overEmit.a, nested2 = __rest(_b, []), _c = overEmit.b, { z } = _c, c = __rest(_c, ["z"]), rest2 = __rest(overEmit, ["a", "b"]);
|
||||
([_d, ...y] = overEmit.a, nested2 = __rest(_d, []), _e = overEmit.b, { z } = _e, c = __rest(_e, ["z"]), rest2 = __rest(overEmit, ["a", "b"]));
|
||||
var _a, _d, _e;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/types/rest/objectRestNegative.ts(2,10): error TS2462: A rest element must be last in a destructuring pattern
|
||||
tests/cases/conformance/types/rest/objectRestNegative.ts(3,31): error TS2462: A rest element must be last in a destructuring pattern
|
||||
tests/cases/conformance/types/rest/objectRestNegative.ts(6,17): error TS2700: Rest types may only be created from object types.
|
||||
tests/cases/conformance/types/rest/objectRestNegative.ts(11,9): error TS2701: An object rest element must be an identifier.
|
||||
tests/cases/conformance/types/rest/objectRestNegative.ts(11,9): error TS2701: The target of an object rest assignment must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/rest/objectRestNegative.ts (4 errors) ====
|
||||
|
@ -23,5 +23,5 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(11,9): error TS2701: An
|
|||
let rest: { b: string }
|
||||
({a, ...rest.b + rest.b} = o);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2701: An object rest element must be an identifier.
|
||||
!!! error TS2701: The target of an object rest assignment must be a variable or a property access.
|
||||
|
|
@ -29,4 +29,4 @@ function generic(t) {
|
|||
return rest;
|
||||
}
|
||||
var rest;
|
||||
(a = o.a, o, o);
|
||||
(a = o.a, o, rest.b + rest.b = __rest(o, ["a"]));
|
||||
|
|
Loading…
Reference in a new issue