mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #2754 from Microsoft/destructuringFixes
Destructuring fixes
This commit is contained in:
+56
-30
@@ -2197,25 +2197,7 @@ module ts {
|
||||
}
|
||||
else if (hasSpreadElement) {
|
||||
let unionOfElements = getUnionType(elementTypes);
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// If the user has something like:
|
||||
//
|
||||
// function fun(...[a, ...b]) { }
|
||||
//
|
||||
// Normally, in ES6, the implied type of an array binding pattern with a rest element is
|
||||
// an iterable. However, there is a requirement in our type system that all rest
|
||||
// parameters be array types. To satisfy this, we have an exception to the rule that
|
||||
// says the type of an array binding pattern with a rest element is an array type
|
||||
// if it is *itself* in a rest parameter. It will still be compatible with a spreaded
|
||||
// iterable argument, but within the function it will be an array.
|
||||
let parent = pattern.parent;
|
||||
let isRestParameter = parent.kind === SyntaxKind.Parameter &&
|
||||
pattern === (<ParameterDeclaration>parent).name &&
|
||||
(<ParameterDeclaration>parent).dotDotDotToken !== undefined;
|
||||
return isRestParameter ? createArrayType(unionOfElements) : createIterableType(unionOfElements);
|
||||
}
|
||||
|
||||
return createArrayType(unionOfElements);
|
||||
return languageVersion >= ScriptTarget.ES6 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
|
||||
}
|
||||
|
||||
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
|
||||
@@ -6035,14 +6017,38 @@ module ts {
|
||||
}
|
||||
let hasSpreadElement = false;
|
||||
let elementTypes: Type[] = [];
|
||||
let inDestructuringPattern = isAssignmentTarget(node);
|
||||
for (let e of elements) {
|
||||
let type = checkExpression(e, contextualMapper);
|
||||
elementTypes.push(type);
|
||||
if (inDestructuringPattern && e.kind === SyntaxKind.SpreadElementExpression) {
|
||||
// Given the following situation:
|
||||
// var c: {};
|
||||
// [...c] = ["", 0];
|
||||
//
|
||||
// c is represented in the tree as a spread element in an array literal.
|
||||
// But c really functions as a rest element, and its purpose is to provide
|
||||
// a contextual type for the right hand side of the assignment. Therefore,
|
||||
// instead of calling checkExpression on "...c", which will give an error
|
||||
// if c is not iterable/array-like, we need to act as if we are trying to
|
||||
// get the contextual element type from it. So we do something similar to
|
||||
// getContextualTypeForElementExpression, which will crucially not error
|
||||
// if there is no index type / iterated type.
|
||||
let restArrayType = checkExpression((<SpreadElementExpression>e).expression, contextualMapper);
|
||||
let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) ||
|
||||
(languageVersion >= ScriptTarget.ES6 ? checkIteratedType(restArrayType, /*expressionForError*/ undefined) : undefined);
|
||||
|
||||
if (restElementType) {
|
||||
elementTypes.push(restElementType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
let type = checkExpression(e, contextualMapper);
|
||||
elementTypes.push(type);
|
||||
}
|
||||
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
|
||||
}
|
||||
if (!hasSpreadElement) {
|
||||
let contextualType = getContextualType(node);
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || isAssignmentTarget(node)) {
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
|
||||
return createTupleType(elementTypes);
|
||||
}
|
||||
}
|
||||
@@ -7633,7 +7639,7 @@ module ts {
|
||||
// This elementType will be used if the specific property corresponding to this index is not
|
||||
// present (aka the tuple element property). This call also checks that the parentType is in
|
||||
// fact an iterable or array (depending on target language).
|
||||
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
|
||||
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType;
|
||||
let elements = node.elements;
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let e = elements[i];
|
||||
@@ -7657,11 +7663,17 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
checkReferenceAssignment((<SpreadElementExpression>e).expression, createArrayType(elementType), contextualMapper);
|
||||
if (i < elements.length - 1) {
|
||||
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
}
|
||||
else {
|
||||
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
let restExpression = (<SpreadElementExpression>e).expression;
|
||||
if (restExpression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>restExpression).operatorToken.kind === SyntaxKind.EqualsToken) {
|
||||
error((<BinaryExpression>restExpression).operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
}
|
||||
else {
|
||||
checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8121,10 +8133,11 @@ module ts {
|
||||
if (node.questionToken && isBindingPattern(node.name) && func.body) {
|
||||
error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
|
||||
}
|
||||
if (node.dotDotDotToken) {
|
||||
if (!isArrayType(getTypeOfSymbol(node.symbol))) {
|
||||
error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
||||
}
|
||||
|
||||
// Only check rest parameter type if it's not a binding pattern. Since binding patterns are
|
||||
// not allowed in a rest parameter, we already have an error from checkGrammarParameterList.
|
||||
if (node.dotDotDotToken && !isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) {
|
||||
error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9427,6 +9440,10 @@ module ts {
|
||||
}
|
||||
|
||||
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
|
||||
if (inputType.flags & TypeFlags.Any) {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
return checkIteratedType(inputType, errorNode) || anyType;
|
||||
}
|
||||
@@ -12270,6 +12287,10 @@ module ts {
|
||||
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
||||
}
|
||||
|
||||
if (isBindingPattern(parameter.name)) {
|
||||
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
|
||||
}
|
||||
|
||||
if (parameter.questionToken) {
|
||||
return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional);
|
||||
}
|
||||
@@ -12756,6 +12777,11 @@ module ts {
|
||||
if (node !== elements[elements.length - 1]) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
}
|
||||
|
||||
if (node.name.kind === SyntaxKind.ArrayBindingPattern || node.name.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
|
||||
}
|
||||
|
||||
if (node.initializer) {
|
||||
// Error on equals token which immediate precedes the initializer
|
||||
return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
|
||||
@@ -363,6 +363,7 @@ module ts {
|
||||
External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." },
|
||||
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
|
||||
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
|
||||
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
|
||||
@@ -1439,6 +1439,10 @@
|
||||
"category": "Error",
|
||||
"code": 2500
|
||||
},
|
||||
"A rest element cannot contain a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 2501
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
+57
-53
@@ -1589,23 +1589,40 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
|
||||
function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression {
|
||||
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
result.expression = expression;
|
||||
result.expression = parenthesizeForAccess(expression);
|
||||
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
|
||||
result.name = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
|
||||
function createElementAccessExpression(expression: Expression, argumentExpression: Expression): ElementAccessExpression {
|
||||
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
result.expression = expression;
|
||||
result.expression = parenthesizeForAccess(expression);
|
||||
result.argumentExpression = argumentExpression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||
// to parenthesize the expression before a dot. The known exceptions are:
|
||||
//
|
||||
// NewExpression:
|
||||
// new C.x -> not the same as (new C).x
|
||||
// NumberLiteral
|
||||
// 1.x -> not the same as (1).x
|
||||
//
|
||||
if (isLeftHandSideExpression(expr) && expr.kind !== SyntaxKind.NewExpression && expr.kind !== SyntaxKind.NumericLiteral) {
|
||||
return <LeftHandSideExpression>expr;
|
||||
}
|
||||
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
node.expression = expr;
|
||||
return node;
|
||||
}
|
||||
|
||||
function emitComputedPropertyName(node: ComputedPropertyName) {
|
||||
write("[");
|
||||
emitExpressionForPropertyName(node);
|
||||
@@ -2276,7 +2293,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (node.initializer.kind === SyntaxKind.ArrayLiteralExpression || node.initializer.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
// This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause
|
||||
// the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash.
|
||||
emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined, /*locationForCheckingExistingName*/ node);
|
||||
emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(assignmentExpression);
|
||||
@@ -2480,16 +2497,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the root has a chance of being a synthesized node, callers should also pass a value for
|
||||
* lowestNonSynthesizedAncestor. This should be an ancestor of root, it should not be synthesized,
|
||||
* and there should not be a lower ancestor that introduces a scope. This node will be used as the
|
||||
* location for ensuring that temporary names are unique.
|
||||
*/
|
||||
function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration,
|
||||
isAssignmentExpressionStatement: boolean,
|
||||
value?: Expression,
|
||||
lowestNonSynthesizedAncestor?: Node) {
|
||||
function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, isAssignmentExpressionStatement: boolean, value?: Expression) {
|
||||
let emitCount = 0;
|
||||
// An exported declaration is actually emitted as an assignment (to a property on the module object), so
|
||||
// temporary variables in an exported declaration need to have real declarations elsewhere
|
||||
@@ -2520,9 +2528,6 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
|
||||
function ensureIdentifier(expr: Expression): Expression {
|
||||
if (expr.kind !== SyntaxKind.Identifier) {
|
||||
// In case the root is a synthesized node, we need to pass lowestNonSynthesizedAncestor
|
||||
// as the location for determining uniqueness of the variable we are about to
|
||||
// generate.
|
||||
let identifier = createTempVariable(TempFlags.Auto);
|
||||
if (!isDeclaration) {
|
||||
recordTempDeclaration(identifier);
|
||||
@@ -2561,27 +2566,22 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return node;
|
||||
}
|
||||
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
if (expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.PropertyAccessExpression || expr.kind === SyntaxKind.ElementAccessExpression) {
|
||||
return <LeftHandSideExpression>expr;
|
||||
}
|
||||
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
node.expression = expr;
|
||||
return node;
|
||||
}
|
||||
|
||||
function createPropertyAccess(object: Expression, propName: Identifier): Expression {
|
||||
function createPropertyAccessForDestructuringProperty(object: Expression, propName: Identifier | LiteralExpression): Expression {
|
||||
if (propName.kind !== SyntaxKind.Identifier) {
|
||||
return createElementAccess(object, propName);
|
||||
return createElementAccessExpression(object, propName);
|
||||
}
|
||||
return createPropertyAccessExpression(parenthesizeForAccess(object), propName);
|
||||
|
||||
return createPropertyAccessExpression(object, propName);
|
||||
}
|
||||
|
||||
function createElementAccess(object: Expression, index: Expression): Expression {
|
||||
let node = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
node.expression = parenthesizeForAccess(object);
|
||||
node.argumentExpression = index;
|
||||
return node;
|
||||
function createSliceCall(value: Expression, sliceIndex: number): CallExpression {
|
||||
let call = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
|
||||
let sliceIdentifier = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
sliceIdentifier.text = "slice";
|
||||
call.expression = createPropertyAccessExpression(value, sliceIdentifier);
|
||||
call.arguments = <NodeArray<LiteralExpression>>createSynthesizedNodeArray();
|
||||
call.arguments[0] = createNumericLiteral(sliceIndex);
|
||||
return call;
|
||||
}
|
||||
|
||||
function emitObjectLiteralAssignment(target: ObjectLiteralExpression, value: Expression) {
|
||||
@@ -2594,8 +2594,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
for (let p of properties) {
|
||||
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
// TODO(andersh): Computed property support
|
||||
let propName = <Identifier>((<PropertyAssignment>p).name);
|
||||
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccess(value, propName));
|
||||
let propName = <Identifier | LiteralExpression>((<PropertyAssignment>p).name);
|
||||
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccessForDestructuringProperty(value, propName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2611,14 +2611,10 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
let e = elements[i];
|
||||
if (e.kind !== SyntaxKind.OmittedExpression) {
|
||||
if (e.kind !== SyntaxKind.SpreadElementExpression) {
|
||||
emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i)));
|
||||
emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)));
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
value = ensureIdentifier(value);
|
||||
emitAssignment(<Identifier>(<SpreadElementExpression>e).expression, value);
|
||||
write(".slice(" + i + ")");
|
||||
}
|
||||
else if (i === elements.length - 1) {
|
||||
emitDestructuringAssignment((<SpreadElementExpression>e).expression, createSliceCall(value, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2682,19 +2678,15 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
// Rewrite element to a declaration with an initializer that fetches property
|
||||
let propName = element.propertyName || <Identifier>element.name;
|
||||
emitBindingElement(element, createPropertyAccess(value, propName));
|
||||
emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName));
|
||||
}
|
||||
else if (element.kind !== SyntaxKind.OmittedExpression) {
|
||||
if (!element.dotDotDotToken) {
|
||||
// Rewrite element to a declaration that accesses array element at index i
|
||||
emitBindingElement(element, createElementAccess(value, createNumericLiteral(i)));
|
||||
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
value = ensureIdentifier(value);
|
||||
emitAssignment(<Identifier>element.name, value);
|
||||
write(".slice(" + i + ")");
|
||||
}
|
||||
else if (i === elements.length - 1) {
|
||||
emitBindingElement(element, createSliceCall(value, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2862,6 +2854,12 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
let tempIndex = 0;
|
||||
forEach(node.parameters, p => {
|
||||
// A rest parameter cannot have a binding pattern or an initializer,
|
||||
// so let's just ignore it.
|
||||
if (p.dotDotDotToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBindingPattern(p.name)) {
|
||||
writeLine();
|
||||
write("var ");
|
||||
@@ -2892,6 +2890,12 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
let restIndex = node.parameters.length - 1;
|
||||
let restParam = node.parameters[restIndex];
|
||||
|
||||
// A rest parameter cannot have a binding pattern, so let's just ignore it if it does.
|
||||
if (isBindingPattern(restParam.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tempName = createTempVariable(TempFlags._i).text;
|
||||
writeLine();
|
||||
emitLeadingComments(restParam);
|
||||
|
||||
@@ -1165,6 +1165,13 @@ module ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createSynthesizedNodeArray(): NodeArray<any> {
|
||||
var array = <NodeArray<any>>[];
|
||||
array.pos = -1;
|
||||
array.end = -1;
|
||||
return array;
|
||||
}
|
||||
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
let nonFileDiagnostics: Diagnostic[] = [];
|
||||
let fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
@@ -1904,4 +1911,4 @@ module ts {
|
||||
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [arrayAssignmentPatternWithAny.ts]
|
||||
var a: any;
|
||||
var x: string;
|
||||
[x] = a;
|
||||
|
||||
//// [arrayAssignmentPatternWithAny.js]
|
||||
var a;
|
||||
var x;
|
||||
x = a[0];
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/destructuring/arrayAssignmentPatternWithAny.ts ===
|
||||
var a: any;
|
||||
>a : Symbol(a, Decl(arrayAssignmentPatternWithAny.ts, 0, 3))
|
||||
|
||||
var x: string;
|
||||
>x : Symbol(x, Decl(arrayAssignmentPatternWithAny.ts, 1, 3))
|
||||
|
||||
[x] = a;
|
||||
>x : Symbol(x, Decl(arrayAssignmentPatternWithAny.ts, 1, 3))
|
||||
>a : Symbol(a, Decl(arrayAssignmentPatternWithAny.ts, 0, 3))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/es6/destructuring/arrayAssignmentPatternWithAny.ts ===
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var x: string;
|
||||
>x : string
|
||||
|
||||
[x] = a;
|
||||
>[x] = a : any
|
||||
>[x] : [string]
|
||||
>x : string
|
||||
>a : any
|
||||
|
||||
@@ -14,7 +14,6 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(3
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,1): error TS2461: Type 'any' is not an array type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
@@ -39,7 +38,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ====
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
|
||||
@@ -110,8 +109,6 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
|
||||
// array literals
|
||||
['', ''] = value;
|
||||
~~~~~~~~
|
||||
!!! error TS2461: Type 'any' is not an array type.
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~~
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,5): error TS2304: Cannot find name 'c'.
|
||||
tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS2304: Cannot find name 'tupel'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts (2 errors) ====
|
||||
var tuple: [string, number];
|
||||
[...c] = tupel; // intentionally misspelled
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'c'.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'tupel'.
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [assignmentRestElementWithErrorSourceType.ts]
|
||||
var tuple: [string, number];
|
||||
[...c] = tupel; // intentionally misspelled
|
||||
|
||||
//// [assignmentRestElementWithErrorSourceType.js]
|
||||
var tuple;
|
||||
c = tupel.slice(0); // intentionally misspelled
|
||||
@@ -11,7 +11,7 @@ var [x3, y3, z3] = a; // emit x3, y3, z3
|
||||
|
||||
//// [declarationEmitDestructuringArrayPattern1.js]
|
||||
var _a = [1, "hello"]; // Dont emit anything
|
||||
var x = ([1, "hello"])[0]; // emit x: number
|
||||
var x = [1, "hello"][0]; // emit x: number
|
||||
var _b = [1, "hello"], x1 = _b[0], y1 = _b[1]; // emit x1: number, y1: string
|
||||
var _c = [0, 1, 2], z1 = _c[2]; // emit z1: number
|
||||
var a = [1, "hello"];
|
||||
|
||||
@@ -10,14 +10,14 @@ var [x18, y18, ...a12] = [1, "hello", true];
|
||||
var [x19, y19, z19, ...a13] = [1, "hello", true];
|
||||
|
||||
//// [declarationEmitDestructuringArrayPattern4.js]
|
||||
var _a = [1, 2, 3], a5 = _a.slice(0);
|
||||
var _b = [1, 2, 3], x14 = _b[0], a6 = _b.slice(1);
|
||||
var _c = [1, 2, 3], x15 = _c[0], y15 = _c[1], a7 = _c.slice(2);
|
||||
var _d = [1, 2, 3], x16 = _d[0], y16 = _d[1], z16 = _d[2], a8 = _d.slice(3);
|
||||
var _e = [1, "hello", true], a9 = _e.slice(0);
|
||||
var _f = [1, "hello", true], x17 = _f[0], a10 = _f.slice(1);
|
||||
var _g = [1, "hello", true], x18 = _g[0], y18 = _g[1], a12 = _g.slice(2);
|
||||
var _h = [1, "hello", true], x19 = _h[0], y19 = _h[1], z19 = _h[2], a13 = _h.slice(3);
|
||||
var a5 = [1, 2, 3].slice(0);
|
||||
var _a = [1, 2, 3], x14 = _a[0], a6 = _a.slice(1);
|
||||
var _b = [1, 2, 3], x15 = _b[0], y15 = _b[1], a7 = _b.slice(2);
|
||||
var _c = [1, 2, 3], x16 = _c[0], y16 = _c[1], z16 = _c[2], a8 = _c.slice(3);
|
||||
var a9 = [1, "hello", true].slice(0);
|
||||
var _d = [1, "hello", true], x17 = _d[0], a10 = _d.slice(1);
|
||||
var _e = [1, "hello", true], x18 = _e[0], y18 = _e[1], a12 = _e.slice(2);
|
||||
var _f = [1, "hello", true], x19 = _f[0], y19 = _f[1], z19 = _f[2], a13 = _f.slice(3);
|
||||
|
||||
|
||||
//// [declarationEmitDestructuringArrayPattern4.d.ts]
|
||||
|
||||
@@ -24,11 +24,11 @@ module m {
|
||||
|
||||
//// [declarationEmitDestructuringObjectLiteralPattern.js]
|
||||
var _a = { x: 5, y: "hello" };
|
||||
var x4 = ({ x4: 5, y4: "hello" }).x4;
|
||||
var y5 = ({ x5: 5, y5: "hello" }).y5;
|
||||
var x4 = { x4: 5, y4: "hello" }.x4;
|
||||
var y5 = { x5: 5, y5: "hello" }.y5;
|
||||
var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6;
|
||||
var a1 = ({ x7: 5, y7: "hello" }).x7;
|
||||
var b1 = ({ x8: 5, y8: "hello" }).y8;
|
||||
var a1 = { x7: 5, y7: "hello" }.x7;
|
||||
var b1 = { x8: 5, y8: "hello" }.y8;
|
||||
var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9;
|
||||
var _d = { a: 1, b: { a: "hello", b: { a: true } } }, x11 = _d.a, _e = _d.b, y11 = _e.a, z11 = _e.b.a;
|
||||
function f15() {
|
||||
|
||||
@@ -10,11 +10,11 @@ var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
|
||||
//// [declarationEmitDestructuringObjectLiteralPattern1.js]
|
||||
var _a = { x: 5, y: "hello" };
|
||||
var x4 = ({ x4: 5, y4: "hello" }).x4;
|
||||
var y5 = ({ x5: 5, y5: "hello" }).y5;
|
||||
var x4 = { x4: 5, y4: "hello" }.x4;
|
||||
var y5 = { x5: 5, y5: "hello" }.y5;
|
||||
var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6;
|
||||
var a1 = ({ x7: 5, y7: "hello" }).x7;
|
||||
var b1 = ({ x8: 5, y8: "hello" }).y8;
|
||||
var a1 = { x7: 5, y7: "hello" }.x7;
|
||||
var b1 = { x8: 5, y8: "hello" }.y8;
|
||||
var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9;
|
||||
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ function f21() {
|
||||
//// [declarationsAndAssignments.js]
|
||||
function f0() {
|
||||
var _a = [1, "hello"];
|
||||
var x = ([1, "hello"])[0];
|
||||
var x = [1, "hello"][0];
|
||||
var _b = [1, "hello"], x = _b[0], y = _b[1];
|
||||
var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2]; // Error
|
||||
var _d = [0, 1, 2], z = _d[2];
|
||||
@@ -201,13 +201,13 @@ function f1() {
|
||||
}
|
||||
function f2() {
|
||||
var _a = { x: 5, y: "hello" };
|
||||
var x = ({ x: 5, y: "hello" }).x;
|
||||
var y = ({ x: 5, y: "hello" }).y;
|
||||
var x = { x: 5, y: "hello" }.x;
|
||||
var y = { x: 5, y: "hello" }.y;
|
||||
var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y;
|
||||
var x;
|
||||
var y;
|
||||
var a = ({ x: 5, y: "hello" }).x;
|
||||
var b = ({ x: 5, y: "hello" }).y;
|
||||
var a = { x: 5, y: "hello" }.x;
|
||||
var b = { x: 5, y: "hello" }.y;
|
||||
var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y;
|
||||
var a;
|
||||
var b;
|
||||
@@ -312,7 +312,7 @@ function f19() {
|
||||
_a = [1, 2], a = _a[0], b = _a[1];
|
||||
_b = [b, a], a = _b[0], b = _b[1];
|
||||
(_c = { b: b, a: a }, a = _c.a, b = _c.b, _c);
|
||||
_d = ([[2, 3]])[0], _e = _d === void 0 ? [1, 2] : _d, a = _e[0], b = _e[1];
|
||||
_d = [[2, 3]][0], _e = _d === void 0 ? [1, 2] : _d, a = _e[0], b = _e[1];
|
||||
var x = (_f = [1, 2], a = _f[0], b = _f[1], _f);
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
}
|
||||
@@ -321,28 +321,28 @@ function f20() {
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
var _a = [1, 2, 3], a = _a.slice(0);
|
||||
var _b = [1, 2, 3], x = _b[0], a = _b.slice(1);
|
||||
var _c = [1, 2, 3], x = _c[0], y = _c[1], a = _c.slice(2);
|
||||
var _d = [1, 2, 3], x = _d[0], y = _d[1], z = _d[2], a = _d.slice(3);
|
||||
_e = [1, 2, 3], a = _e.slice(0);
|
||||
_f = [1, 2, 3], x = _f[0], a = _f.slice(1);
|
||||
_g = [1, 2, 3], x = _g[0], y = _g[1], a = _g.slice(2);
|
||||
_h = [1, 2, 3], x = _h[0], y = _h[1], z = _h[2], a = _h.slice(3);
|
||||
var _e, _f, _g, _h;
|
||||
var a = [1, 2, 3].slice(0);
|
||||
var _a = [1, 2, 3], x = _a[0], a = _a.slice(1);
|
||||
var _b = [1, 2, 3], x = _b[0], y = _b[1], a = _b.slice(2);
|
||||
var _c = [1, 2, 3], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3);
|
||||
a = [1, 2, 3].slice(0);
|
||||
_d = [1, 2, 3], x = _d[0], a = _d.slice(1);
|
||||
_e = [1, 2, 3], x = _e[0], y = _e[1], a = _e.slice(2);
|
||||
_f = [1, 2, 3], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3);
|
||||
var _d, _e, _f;
|
||||
}
|
||||
function f21() {
|
||||
var a;
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
var _a = [1, "hello", true], a = _a.slice(0);
|
||||
var _b = [1, "hello", true], x = _b[0], a = _b.slice(1);
|
||||
var _c = [1, "hello", true], x = _c[0], y = _c[1], a = _c.slice(2);
|
||||
var _d = [1, "hello", true], x = _d[0], y = _d[1], z = _d[2], a = _d.slice(3);
|
||||
_e = [1, "hello", true], a = _e.slice(0);
|
||||
_f = [1, "hello", true], x = _f[0], a = _f.slice(1);
|
||||
_g = [1, "hello", true], x = _g[0], y = _g[1], a = _g.slice(2);
|
||||
_h = [1, "hello", true], x = _h[0], y = _h[1], z = _h[2], a = _h.slice(3);
|
||||
var _e, _f, _g, _h;
|
||||
var a = [1, "hello", true].slice(0);
|
||||
var _a = [1, "hello", true], x = _a[0], a = _a.slice(1);
|
||||
var _b = [1, "hello", true], x = _b[0], y = _b[1], a = _b.slice(2);
|
||||
var _c = [1, "hello", true], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3);
|
||||
a = [1, "hello", true].slice(0);
|
||||
_d = [1, "hello", true], x = _d[0], a = _d.slice(1);
|
||||
_e = [1, "hello", true], x = _e[0], y = _e[1], a = _e.slice(2);
|
||||
_f = [1, "hello", true], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3);
|
||||
var _d, _e, _f;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [destructuringWithNewExpression.ts]
|
||||
class C {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var { x } = new C;
|
||||
|
||||
//// [destructuringWithNewExpression.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.x = 0;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var x = (new C).x;
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/destructuringWithNewExpression.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(destructuringWithNewExpression.ts, 0, 0))
|
||||
|
||||
x = 0;
|
||||
>x : Symbol(x, Decl(destructuringWithNewExpression.ts, 0, 9))
|
||||
}
|
||||
|
||||
var { x } = new C;
|
||||
>x : Symbol(x, Decl(destructuringWithNewExpression.ts, 4, 5))
|
||||
>C : Symbol(C, Decl(destructuringWithNewExpression.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/destructuringWithNewExpression.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
x = 0;
|
||||
>x : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
var { x } = new C;
|
||||
>x : number
|
||||
>new C : C
|
||||
>C : typeof C
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringWithNumberLiteral.ts]
|
||||
var { toExponential } = 0;
|
||||
|
||||
//// [destructuringWithNumberLiteral.js]
|
||||
var toExponential = (0).toExponential;
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/compiler/destructuringWithNumberLiteral.ts ===
|
||||
var { toExponential } = 0;
|
||||
>toExponential : Symbol(toExponential, Decl(destructuringWithNumberLiteral.ts, 0, 5))
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/destructuringWithNumberLiteral.ts ===
|
||||
var { toExponential } = 0;
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
>0 : number
|
||||
|
||||
@@ -16,7 +16,7 @@ const {a: baz4} = { a: 1 };
|
||||
// top level let\const should not be renamed
|
||||
var foo;
|
||||
var bar = 1;
|
||||
var baz = ([])[0];
|
||||
var baz2 = ({ a: 1 }).a;
|
||||
var baz3 = ([])[0];
|
||||
var baz4 = ({ a: 1 }).a;
|
||||
var baz = [][0];
|
||||
var baz2 = { a: 1 }.a;
|
||||
var baz3 = [][0];
|
||||
var baz4 = { a: 1 }.a;
|
||||
|
||||
@@ -24,16 +24,16 @@ export module M {
|
||||
// exported let\const bindings should not be renamed
|
||||
exports.foo = 10;
|
||||
exports.bar = "123";
|
||||
exports.bar1 = ([1])[0];
|
||||
exports.bar2 = ([2])[0];
|
||||
exports.bar3 = ({ a: 1 }).a;
|
||||
exports.bar4 = ({ a: 1 }).a;
|
||||
exports.bar1 = [1][0];
|
||||
exports.bar2 = [2][0];
|
||||
exports.bar3 = { a: 1 }.a;
|
||||
exports.bar4 = { a: 1 }.a;
|
||||
var M;
|
||||
(function (M) {
|
||||
M.baz = 100;
|
||||
M.baz2 = true;
|
||||
M.bar5 = ([1])[0];
|
||||
M.bar6 = ([2])[0];
|
||||
M.bar7 = ({ a: 1 }).a;
|
||||
M.bar8 = ({ a: 1 }).a;
|
||||
M.bar5 = [1][0];
|
||||
M.bar6 = [2][0];
|
||||
M.bar7 = { a: 1 }.a;
|
||||
M.bar8 = { a: 1 }.a;
|
||||
})(M = exports.M || (exports.M = {}));
|
||||
|
||||
@@ -61,13 +61,13 @@ var z0, z1, z2, z3;
|
||||
{
|
||||
var x_1 = 20;
|
||||
use(x_1);
|
||||
var z0_1 = ([1])[0];
|
||||
var z0_1 = [1][0];
|
||||
use(z0_1);
|
||||
var z1_1 = ([1])[0];
|
||||
var z1_1 = [1][0];
|
||||
use(z1_1);
|
||||
var z2_1 = ({ a: 1 }).a;
|
||||
var z2_1 = { a: 1 }.a;
|
||||
use(z2_1);
|
||||
var z3_1 = ({ a: 1 }).a;
|
||||
var z3_1 = { a: 1 }.a;
|
||||
use(z3_1);
|
||||
}
|
||||
use(x);
|
||||
@@ -79,10 +79,10 @@ var z6;
|
||||
var y = true;
|
||||
{
|
||||
var y_1 = "";
|
||||
var z6_1 = ([true])[0];
|
||||
var z6_1 = [true][0];
|
||||
{
|
||||
var y_2 = 1;
|
||||
var z6_2 = ({ a: 1 }).a;
|
||||
var z6_2 = { a: 1 }.a;
|
||||
use(y_2);
|
||||
use(z6_2);
|
||||
}
|
||||
@@ -95,10 +95,10 @@ var z = false;
|
||||
var z5 = 1;
|
||||
{
|
||||
var z_1 = "";
|
||||
var z5_1 = ([5])[0];
|
||||
var z5_1 = [5][0];
|
||||
{
|
||||
var _z = 1;
|
||||
var _z5 = ({ a: 1 }).a;
|
||||
var _z5 = { a: 1 }.a;
|
||||
// try to step on generated name
|
||||
use(_z);
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ var z0, z1, z2, z3;
|
||||
{
|
||||
var x_1 = 20;
|
||||
use(x_1);
|
||||
var z0_1 = ([1])[0];
|
||||
var z0_1 = [1][0];
|
||||
use(z0_1);
|
||||
var z1_1 = ([{ a: 1 }])[0].a;
|
||||
var z1_1 = [{ a: 1 }][0].a;
|
||||
use(z1_1);
|
||||
var z2_1 = ({ a: 1 }).a;
|
||||
var z2_1 = { a: 1 }.a;
|
||||
use(z2_1);
|
||||
var z3_1 = ({ a: { b: 1 } }).a.b;
|
||||
var z3_1 = { a: { b: 1 } }.a.b;
|
||||
use(z3_1);
|
||||
}
|
||||
use(x);
|
||||
@@ -79,10 +79,10 @@ var z6;
|
||||
var y = true;
|
||||
{
|
||||
var y_1 = "";
|
||||
var z6_1 = ([true])[0];
|
||||
var z6_1 = [true][0];
|
||||
{
|
||||
var y_2 = 1;
|
||||
var z6_2 = ({ a: 1 }).a;
|
||||
var z6_2 = { a: 1 }.a;
|
||||
use(y_2);
|
||||
use(z6_2);
|
||||
}
|
||||
@@ -95,10 +95,10 @@ var z = false;
|
||||
var z5 = 1;
|
||||
{
|
||||
var z_1 = "";
|
||||
var z5_1 = ([5])[0];
|
||||
var z5_1 = [5][0];
|
||||
{
|
||||
var _z = 1;
|
||||
var _z5 = ({ a: 1 }).a;
|
||||
var _z5 = { a: 1 }.a;
|
||||
// try to step on generated name
|
||||
use(_z);
|
||||
}
|
||||
|
||||
@@ -238,18 +238,18 @@ use(z);
|
||||
function foo1() {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
}
|
||||
function foo2() {
|
||||
{
|
||||
var x_1 = 1;
|
||||
use(x_1);
|
||||
var y_1 = ([1])[0];
|
||||
var y_1 = [1][0];
|
||||
use(y_1);
|
||||
var z_1 = ({ a: 1 }).a;
|
||||
var z_1 = { a: 1 }.a;
|
||||
use(z_1);
|
||||
}
|
||||
use(x);
|
||||
@@ -260,18 +260,18 @@ var A = (function () {
|
||||
A.prototype.m1 = function () {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
};
|
||||
A.prototype.m2 = function () {
|
||||
{
|
||||
var x_2 = 1;
|
||||
use(x_2);
|
||||
var y_2 = ([1])[0];
|
||||
var y_2 = [1][0];
|
||||
use(y_2);
|
||||
var z_2 = ({ a: 1 }).a;
|
||||
var z_2 = { a: 1 }.a;
|
||||
use(z_2);
|
||||
}
|
||||
use(x);
|
||||
@@ -284,18 +284,18 @@ var B = (function () {
|
||||
B.prototype.m1 = function () {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
};
|
||||
B.prototype.m2 = function () {
|
||||
{
|
||||
var x_3 = 1;
|
||||
use(x_3);
|
||||
var y_3 = ([1])[0];
|
||||
var y_3 = [1][0];
|
||||
use(y_3);
|
||||
var z_3 = ({ a: 1 }).a;
|
||||
var z_3 = { a: 1 }.a;
|
||||
use(z_3);
|
||||
}
|
||||
use(x);
|
||||
@@ -305,18 +305,18 @@ var B = (function () {
|
||||
function bar1() {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
}
|
||||
function bar2() {
|
||||
{
|
||||
var x_4 = 1;
|
||||
use(x_4);
|
||||
var y_4 = ([1])[0];
|
||||
var y_4 = [1][0];
|
||||
use(y_4);
|
||||
var z_4 = ({ a: 1 }).a;
|
||||
var z_4 = { a: 1 }.a;
|
||||
use(z_4);
|
||||
}
|
||||
use(x);
|
||||
@@ -325,9 +325,9 @@ var M1;
|
||||
(function (M1) {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
})(M1 || (M1 = {}));
|
||||
var M2;
|
||||
@@ -335,9 +335,9 @@ var M2;
|
||||
{
|
||||
var x_5 = 1;
|
||||
use(x_5);
|
||||
var y_5 = ([1])[0];
|
||||
var y_5 = [1][0];
|
||||
use(y_5);
|
||||
var z_5 = ({ a: 1 }).a;
|
||||
var z_5 = { a: 1 }.a;
|
||||
use(z_5);
|
||||
}
|
||||
use(x);
|
||||
@@ -346,9 +346,9 @@ var M3;
|
||||
(function (M3) {
|
||||
var x = 1;
|
||||
use(x);
|
||||
var y = ([1])[0];
|
||||
var y = [1][0];
|
||||
use(y);
|
||||
var z = ({ a: 1 }).a;
|
||||
var z = { a: 1 }.a;
|
||||
use(z);
|
||||
})(M3 || (M3 = {}));
|
||||
var M4;
|
||||
@@ -356,9 +356,9 @@ var M4;
|
||||
{
|
||||
var x_6 = 1;
|
||||
use(x_6);
|
||||
var y_6 = ([1])[0];
|
||||
var y_6 = [1][0];
|
||||
use(y_6);
|
||||
var z_6 = ({ a: 1 }).a;
|
||||
var z_6 = { a: 1 }.a;
|
||||
use(z_6);
|
||||
}
|
||||
use(x);
|
||||
@@ -369,10 +369,10 @@ function foo3() {
|
||||
for (var x_7 = void 0;;) {
|
||||
use(x_7);
|
||||
}
|
||||
for (var y_7 = ([])[0];;) {
|
||||
for (var y_7 = [][0];;) {
|
||||
use(y_7);
|
||||
}
|
||||
for (var z_7 = ({ a: 1 }).a;;) {
|
||||
for (var z_7 = { a: 1 }.a;;) {
|
||||
use(z_7);
|
||||
}
|
||||
use(x);
|
||||
@@ -381,10 +381,10 @@ function foo4() {
|
||||
for (var x_8 = 1;;) {
|
||||
use(x_8);
|
||||
}
|
||||
for (var y_8 = ([])[0];;) {
|
||||
for (var y_8 = [][0];;) {
|
||||
use(y_8);
|
||||
}
|
||||
for (var z_8 = ({ a: 1 }).a;;) {
|
||||
for (var z_8 = { a: 1 }.a;;) {
|
||||
use(z_8);
|
||||
}
|
||||
use(x);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
return 103;
|
||||
});
|
||||
(function () {
|
||||
if (arg === void 0) { arg = []; }
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of49.ts(3,13): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of49.ts(3,14): error TS2322: Type 'string | boolean' is not assignable to type 'boolean'.
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of49.ts (1 errors) ====
|
||||
var k: string, v: boolean;
|
||||
var map = new Map([["", true]]);
|
||||
for ([k, ...[v]] of map) {
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2322: Type 'string | boolean' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
k;
|
||||
v;
|
||||
}
|
||||
@@ -25,8 +25,8 @@ if (true) {
|
||||
}
|
||||
var x, y, z;
|
||||
if (true) {
|
||||
var x_1 = ({ x: 0 }).x;
|
||||
var y_1 = ({ y: 0 }).y;
|
||||
var x_1 = { x: 0 }.x;
|
||||
var y_1 = { y: 0 }.y;
|
||||
var z_1;
|
||||
(_a = { z: 0 }, z_1 = _a.z, _a);
|
||||
(_b = { z: 0 }, z_1 = _b.z, _b);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(1,17): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts (1 errors) ====
|
||||
function fun(...[a, ...b]) { }
|
||||
~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
fun(new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts ===
|
||||
function fun(...[a, ...b]) { }
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern14.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(iterableArrayPattern14.ts, 0, 17))
|
||||
>b : Symbol(b, Decl(iterableArrayPattern14.ts, 0, 19))
|
||||
|
||||
fun(new FooIterator);
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern14.ts, 0, 0))
|
||||
>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern14.ts, 3, 27))
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern14.ts, 1, 21))
|
||||
>x : Symbol(x, Decl(iterableArrayPattern14.ts, 2, 11))
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern14.ts, 2, 15))
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern14.ts, 1, 21))
|
||||
>y : Symbol(y, Decl(iterableArrayPattern14.ts, 3, 23))
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern14.ts, 3, 27))
|
||||
|
||||
next() {
|
||||
>next : Symbol(next, Decl(iterableArrayPattern14.ts, 4, 19))
|
||||
|
||||
return {
|
||||
value: new Foo,
|
||||
>value : Symbol(value, Decl(iterableArrayPattern14.ts, 6, 16))
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern14.ts, 2, 15))
|
||||
|
||||
done: false
|
||||
>done : Symbol(done, Decl(iterableArrayPattern14.ts, 7, 27))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
|
||||
return this;
|
||||
>this : Symbol(FooIterator, Decl(iterableArrayPattern14.ts, 3, 27))
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts ===
|
||||
function fun(...[a, ...b]) { }
|
||||
>fun : (...[a, ...b]: any[]) => void
|
||||
>a : any
|
||||
>b : any[]
|
||||
|
||||
fun(new FooIterator);
|
||||
>fun(new FooIterator) : void
|
||||
>fun : (...[a, ...b]: any[]) => void
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Bar
|
||||
>x : any
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
>y : any
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : FooIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: Foo; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
|
||||
|
||||
value: new Foo,
|
||||
>value : Foo
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
>false : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : FooIterator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(1,17): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts (1 errors) ====
|
||||
function fun(...[a, b]: Bar[]) { }
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
fun(...new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts ===
|
||||
function fun(...[a, b]: Bar[]) { }
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern15.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(iterableArrayPattern15.ts, 0, 17))
|
||||
>b : Symbol(b, Decl(iterableArrayPattern15.ts, 0, 19))
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern15.ts, 1, 24))
|
||||
|
||||
fun(...new FooIterator);
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern15.ts, 0, 0))
|
||||
>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern15.ts, 3, 27))
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern15.ts, 1, 24))
|
||||
>x : Symbol(x, Decl(iterableArrayPattern15.ts, 2, 11))
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern15.ts, 2, 15))
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern15.ts, 1, 24))
|
||||
>y : Symbol(y, Decl(iterableArrayPattern15.ts, 3, 23))
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern15.ts, 3, 27))
|
||||
|
||||
next() {
|
||||
>next : Symbol(next, Decl(iterableArrayPattern15.ts, 4, 19))
|
||||
|
||||
return {
|
||||
value: new Foo,
|
||||
>value : Symbol(value, Decl(iterableArrayPattern15.ts, 6, 16))
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern15.ts, 2, 15))
|
||||
|
||||
done: false
|
||||
>done : Symbol(done, Decl(iterableArrayPattern15.ts, 7, 27))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
|
||||
return this;
|
||||
>this : Symbol(FooIterator, Decl(iterableArrayPattern15.ts, 3, 27))
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts ===
|
||||
function fun(...[a, b]: Bar[]) { }
|
||||
>fun : (...[a, b]: Bar[]) => void
|
||||
>a : Bar
|
||||
>b : Bar
|
||||
>Bar : Bar
|
||||
|
||||
fun(...new FooIterator);
|
||||
>fun(...new FooIterator) : void
|
||||
>fun : (...[a, b]: Bar[]) => void
|
||||
>...new FooIterator : Foo
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Bar
|
||||
>x : any
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
>y : any
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : FooIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: Foo; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
|
||||
|
||||
value: new Foo,
|
||||
>value : Foo
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
>false : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : FooIterator
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(1,17): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'.
|
||||
Property '0' is missing in type 'FooIterator'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (2 errors) ====
|
||||
function fun(...[a, b]: [Bar, Bar][]) { }
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
fun(...new FooIteratorIterator);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(1,17): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'.
|
||||
Property 'x' is missing in type 'FooIterator'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (2 errors) ====
|
||||
function fun(...[a, b]: Bar[]) { }
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
fun(new FooIterator);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(1,17): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts (1 errors) ====
|
||||
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
fun(...new FooArrayIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooArrayIterator {
|
||||
next() {
|
||||
return {
|
||||
value: [new Foo],
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts ===
|
||||
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern20.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(iterableArrayPattern20.ts, 0, 18))
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern20.ts, 2, 15))
|
||||
>b : Symbol(b, Decl(iterableArrayPattern20.ts, 0, 31))
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern20.ts, 2, 15))
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern20.ts, 1, 29))
|
||||
|
||||
fun(...new FooArrayIterator);
|
||||
>fun : Symbol(fun, Decl(iterableArrayPattern20.ts, 0, 0))
|
||||
>FooArrayIterator : Symbol(FooArrayIterator, Decl(iterableArrayPattern20.ts, 3, 27))
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern20.ts, 1, 29))
|
||||
>x : Symbol(x, Decl(iterableArrayPattern20.ts, 2, 11))
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern20.ts, 2, 15))
|
||||
>Bar : Symbol(Bar, Decl(iterableArrayPattern20.ts, 1, 29))
|
||||
>y : Symbol(y, Decl(iterableArrayPattern20.ts, 3, 23))
|
||||
|
||||
class FooArrayIterator {
|
||||
>FooArrayIterator : Symbol(FooArrayIterator, Decl(iterableArrayPattern20.ts, 3, 27))
|
||||
|
||||
next() {
|
||||
>next : Symbol(next, Decl(iterableArrayPattern20.ts, 4, 24))
|
||||
|
||||
return {
|
||||
value: [new Foo],
|
||||
>value : Symbol(value, Decl(iterableArrayPattern20.ts, 6, 16))
|
||||
>Foo : Symbol(Foo, Decl(iterableArrayPattern20.ts, 2, 15))
|
||||
|
||||
done: false
|
||||
>done : Symbol(done, Decl(iterableArrayPattern20.ts, 7, 29))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
|
||||
return this;
|
||||
>this : Symbol(FooArrayIterator, Decl(iterableArrayPattern20.ts, 3, 27))
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts ===
|
||||
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
|
||||
>fun : (...[[a = new Foo], b = [new Foo]]: Bar[][]) => void
|
||||
>a : Bar
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
>b : Bar[]
|
||||
>[new Foo] : Foo[]
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
>Bar : Bar
|
||||
|
||||
fun(...new FooArrayIterator);
|
||||
>fun(...new FooArrayIterator) : void
|
||||
>fun : (...[[a = new Foo], b = [new Foo]]: Bar[][]) => void
|
||||
>...new FooArrayIterator : Foo[]
|
||||
>new FooArrayIterator : FooArrayIterator
|
||||
>FooArrayIterator : typeof FooArrayIterator
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Bar
|
||||
>x : any
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
>y : any
|
||||
|
||||
class FooArrayIterator {
|
||||
>FooArrayIterator : FooArrayIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: Foo[]; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: [new Foo], done: false } : { value: Foo[]; done: boolean; }
|
||||
|
||||
value: [new Foo],
|
||||
>value : Foo[]
|
||||
>[new Foo] : Foo[]
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
>false : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : FooArrayIterator
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,30): error TS2370: A rest parameter must be of an array type.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ====
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2370: A rest parameter must be of an array type.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts(2,21): error TS2345: Argument of type 'Map<string, number>' is not assignable to parameter of type '[string, number]'.
|
||||
Property '0' is missing in type 'Map<string, number>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts (2 errors) ====
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'Map<string, number>' is not assignable to parameter of type '[string, number]'.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts (1 errors) ====
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
|
||||
@@ -1,12 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts ===
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
>takeFirstTwoEntries : Symbol(takeFirstTwoEntries, Decl(iterableArrayPattern27.ts, 0, 0))
|
||||
>k1 : Symbol(k1, Decl(iterableArrayPattern27.ts, 0, 34))
|
||||
>v1 : Symbol(v1, Decl(iterableArrayPattern27.ts, 0, 37))
|
||||
>k2 : Symbol(k2, Decl(iterableArrayPattern27.ts, 0, 44))
|
||||
>v2 : Symbol(v2, Decl(iterableArrayPattern27.ts, 0, 47))
|
||||
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
|
||||
>takeFirstTwoEntries : Symbol(takeFirstTwoEntries, Decl(iterableArrayPattern27.ts, 0, 0))
|
||||
>Map : Symbol(Map, Decl(lib.d.ts, 1837, 1), Decl(lib.d.ts, 1859, 11))
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts ===
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
>takeFirstTwoEntries : (...[[k1, v1], [k2, v2]]: [string, number][]) => void
|
||||
>k1 : string
|
||||
>v1 : number
|
||||
>k2 : string
|
||||
>v2 : number
|
||||
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
|
||||
>takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]])) : void
|
||||
>takeFirstTwoEntries : (...[[k1, v1], [k2, v2]]: [string, number][]) => void
|
||||
>...new Map([["", 0], ["hello", 1]]) : [string, number]
|
||||
>new Map([["", 0], ["hello", 1]]) : Map<string, number>
|
||||
>Map : MapConstructor
|
||||
>[["", 0], ["hello", 1]] : [string, number][]
|
||||
>["", 0] : [string, number]
|
||||
>"" : string
|
||||
>0 : number
|
||||
>["hello", 1] : [string, number]
|
||||
>"hello" : string
|
||||
>1 : number
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,28): error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (2 errors) ====
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
|
||||
~~~
|
||||
!!! error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'.
|
||||
Types of property '1' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (2 errors) ====
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'.
|
||||
|
||||
@@ -3,5 +3,5 @@ let [x] = [1];
|
||||
let {a: y} = {a: 1};
|
||||
|
||||
//// [letInNonStrictMode.js]
|
||||
var x = ([1])[0];
|
||||
var y = ({ a: 1 }).a;
|
||||
var x = [1][0];
|
||||
var y = { a: 1 }.a;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [nonIterableRestElement1.ts]
|
||||
var c = {};
|
||||
[...c] = ["", 0];
|
||||
|
||||
//// [nonIterableRestElement1.js]
|
||||
var c = {};
|
||||
c = ["", 0].slice(0);
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement1.ts ===
|
||||
var c = {};
|
||||
>c : Symbol(c, Decl(nonIterableRestElement1.ts, 0, 3))
|
||||
|
||||
[...c] = ["", 0];
|
||||
>c : Symbol(c, Decl(nonIterableRestElement1.ts, 0, 3))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement1.ts ===
|
||||
var c = {};
|
||||
>c : {}
|
||||
>{} : {}
|
||||
|
||||
[...c] = ["", 0];
|
||||
>[...c] = ["", 0] : (string | number)[]
|
||||
>[...c] : {}[]
|
||||
>...c : any
|
||||
>c : {}
|
||||
>["", 0] : (string | number)[]
|
||||
>"" : string
|
||||
>0 : number
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [nonIterableRestElement2.ts]
|
||||
var c = {};
|
||||
[...c] = ["", 0];
|
||||
|
||||
//// [nonIterableRestElement2.js]
|
||||
var c = {};
|
||||
[...c] = ["", 0];
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement2.ts ===
|
||||
var c = {};
|
||||
>c : Symbol(c, Decl(nonIterableRestElement2.ts, 0, 3))
|
||||
|
||||
[...c] = ["", 0];
|
||||
>c : Symbol(c, Decl(nonIterableRestElement2.ts, 0, 3))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement2.ts ===
|
||||
var c = {};
|
||||
>c : {}
|
||||
>{} : {}
|
||||
|
||||
[...c] = ["", 0];
|
||||
>[...c] = ["", 0] : (string | number)[]
|
||||
>[...c] : {}[]
|
||||
>...c : any
|
||||
>c : {}
|
||||
>["", 0] : (string | number)[]
|
||||
>"" : string
|
||||
>0 : number
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/es6/destructuring/nonIterableRestElement3.ts(2,5): error TS2322: Type '(string | number)[]' is not assignable to type '{ bogus: number; }'.
|
||||
Property 'bogus' is missing in type '(string | number)[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/nonIterableRestElement3.ts (1 errors) ====
|
||||
var c = { bogus: 0 };
|
||||
[...c] = ["", 0];
|
||||
~
|
||||
!!! error TS2322: Type '(string | number)[]' is not assignable to type '{ bogus: number; }'.
|
||||
!!! error TS2322: Property 'bogus' is missing in type '(string | number)[]'.
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [nonIterableRestElement3.ts]
|
||||
var c = { bogus: 0 };
|
||||
[...c] = ["", 0];
|
||||
|
||||
//// [nonIterableRestElement3.js]
|
||||
var c = { bogus: 0 };
|
||||
c = ["", 0].slice(0);
|
||||
@@ -8,7 +8,6 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
if (bar === void 0) { bar = 0; }
|
||||
var bar = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
bar[_i - 0] = arguments[_i];
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern1.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern1.ts(2,9): error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern1.ts (2 errors) ====
|
||||
var a: string, b: number;
|
||||
[...[a, b = 0]] = ["", 1];
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [restElementWithAssignmentPattern1.ts]
|
||||
var a: string, b: number;
|
||||
[...[a, b = 0]] = ["", 1];
|
||||
|
||||
//// [restElementWithAssignmentPattern1.js]
|
||||
var a, b;
|
||||
[...[a, b = 0]] = ["", 1];
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern2.ts(2,10): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern2.ts(2,18): error TS2459: Type '(string | number)[]' has no property 'b' and no string index signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern2.ts (2 errors) ====
|
||||
var a: string, b: number;
|
||||
[...{ 0: a = "", b }] = ["", 1];
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2459: Type '(string | number)[]' has no property 'b' and no string index signature.
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [restElementWithAssignmentPattern2.ts]
|
||||
var a: string, b: number;
|
||||
[...{ 0: a = "", b }] = ["", 1];
|
||||
|
||||
//// [restElementWithAssignmentPattern2.js]
|
||||
var a, b;
|
||||
[...{ 0: a = "", b }] = ["", 1];
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern3.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern3.ts(3,9): error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern3.ts (2 errors) ====
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...[a, b = 0]] = tuple;
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [restElementWithAssignmentPattern3.ts]
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...[a, b = 0]] = tuple;
|
||||
|
||||
//// [restElementWithAssignmentPattern3.js]
|
||||
var a, b;
|
||||
var tuple = ["", 1];
|
||||
_a = tuple.slice(0), a = _a[0], _b = _a[1], b = _b === void 0 ? 0 : _b;
|
||||
var _a, _b;
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern4.ts(3,10): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern4.ts(3,18): error TS2459: Type '(string | number)[]' has no property 'b' and no string index signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern4.ts (2 errors) ====
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...{ 0: a = "", b }] = tuple;
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2459: Type '(string | number)[]' has no property 'b' and no string index signature.
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [restElementWithAssignmentPattern4.ts]
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...{ 0: a = "", b }] = tuple;
|
||||
|
||||
//// [restElementWithAssignmentPattern4.js]
|
||||
var a, b;
|
||||
var tuple = ["", 1];
|
||||
_a = tuple.slice(0), _b = _a[0], a = _b === void 0 ? "" : _b, b = _a.b;
|
||||
var _a, _b;
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [restElementWithAssignmentPattern5.ts]
|
||||
var s: string, s2: string;
|
||||
[...[s, s2]] = ["", ""];
|
||||
|
||||
//// [restElementWithAssignmentPattern5.js]
|
||||
var s, s2;
|
||||
_a = ["", ""].slice(0), s = _a[0], s2 = _a[1];
|
||||
var _a;
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern5.ts ===
|
||||
var s: string, s2: string;
|
||||
>s : Symbol(s, Decl(restElementWithAssignmentPattern5.ts, 0, 3))
|
||||
>s2 : Symbol(s2, Decl(restElementWithAssignmentPattern5.ts, 0, 14))
|
||||
|
||||
[...[s, s2]] = ["", ""];
|
||||
>s : Symbol(s, Decl(restElementWithAssignmentPattern5.ts, 0, 3))
|
||||
>s2 : Symbol(s2, Decl(restElementWithAssignmentPattern5.ts, 0, 14))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern5.ts ===
|
||||
var s: string, s2: string;
|
||||
>s : string
|
||||
>s2 : string
|
||||
|
||||
[...[s, s2]] = ["", ""];
|
||||
>[...[s, s2]] = ["", ""] : string[]
|
||||
>[...[s, s2]] : string[]
|
||||
>...[s, s2] : string
|
||||
>[s, s2] : string[]
|
||||
>s : string
|
||||
>s2 : string
|
||||
>["", ""] : string[]
|
||||
>"" : string
|
||||
>"" : string
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern.ts(1,9): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithBindingPattern.ts (1 errors) ====
|
||||
var [...[a, b]] = [0, 1];
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [restElementWithBindingPattern.ts]
|
||||
var [...[a, b]] = [0, 1];
|
||||
|
||||
//// [restElementWithBindingPattern.js]
|
||||
var _a = [0, 1].slice(0), a = _a[0], b = _a[1];
|
||||
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,9): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts(1,16): error TS2459: Type 'number[]' has no property 'b' and no string index signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithBindingPattern2.ts (2 errors) ====
|
||||
var [...{0: a, b }] = [0, 1];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
~
|
||||
!!! error TS2459: Type 'number[]' has no property 'b' and no string index signature.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [restElementWithBindingPattern2.ts]
|
||||
var [...{0: a, b }] = [0, 1];
|
||||
|
||||
//// [restElementWithBindingPattern2.js]
|
||||
var _a = [0, 1].slice(0), a = _a[0], b = _a.b;
|
||||
@@ -5,4 +5,4 @@ var [...x = a] = a; // Error, rest element cannot have initializer
|
||||
|
||||
//// [restElementWithInitializer1.js]
|
||||
var a;
|
||||
var x = a.slice(0); // Error, rest element cannot have initializer
|
||||
var _a = a.slice(0), x = _a === void 0 ? a : _a; // Error, rest element cannot have initializer
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/destructuring/restElementWithInitializer2.ts(3,5): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es6/destructuring/restElementWithInitializer2.ts(3,7): error TS1186: A rest element cannot have an initializer.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/restElementWithInitializer2.ts (1 errors) ====
|
||||
var a: number[];
|
||||
var x: number[];
|
||||
[...x = a] = a; // Error, rest element cannot have initializer
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS1186: A rest element cannot have an initializer.
|
||||
|
||||
@@ -7,4 +7,5 @@ var x: number[];
|
||||
//// [restElementWithInitializer2.js]
|
||||
var a;
|
||||
var x;
|
||||
x = a = a.slice(0); // Error, rest element cannot have initializer
|
||||
_a = a.slice(0), x = _a === void 0 ? a : _a; // Error, rest element cannot have initializer
|
||||
var _a;
|
||||
|
||||
@@ -14,14 +14,14 @@ function foo4([...r] = []) {
|
||||
|
||||
//// [restElementWithNullInitializer.js]
|
||||
function foo1(_a) {
|
||||
var _b = _a === void 0 ? null : _a, r = _b.slice(0);
|
||||
var r = (_a === void 0 ? null : _a).slice(0);
|
||||
}
|
||||
function foo2(_a) {
|
||||
var _b = _a === void 0 ? undefined : _a, r = _b.slice(0);
|
||||
var r = (_a === void 0 ? undefined : _a).slice(0);
|
||||
}
|
||||
function foo3(_a) {
|
||||
var _b = _a === void 0 ? {} : _a, r = _b.slice(0);
|
||||
var r = (_a === void 0 ? {} : _a).slice(0);
|
||||
}
|
||||
function foo4(_a) {
|
||||
var _b = _a === void 0 ? [] : _a, r = _b.slice(0);
|
||||
var r = (_a === void 0 ? [] : _a).slice(0);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ function f() {
|
||||
}
|
||||
}
|
||||
function f2() {
|
||||
if (x === void 0) { x = []; }
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/restParameterWithBindingPattern1.ts(1,15): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restParameterWithBindingPattern1.ts (1 errors) ====
|
||||
function a(...{a, b}) { }
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [restParameterWithBindingPattern1.ts]
|
||||
function a(...{a, b}) { }
|
||||
|
||||
//// [restParameterWithBindingPattern1.js]
|
||||
function a() { }
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/restParameterWithBindingPattern2.ts(1,15): error TS2501: A rest element cannot contain a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restParameterWithBindingPattern2.ts (1 errors) ====
|
||||
function a(...[a, b]) { }
|
||||
~~~~~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [restParameterWithBindingPattern2.ts]
|
||||
function a(...[a, b]) { }
|
||||
|
||||
//// [restParameterWithBindingPattern2.js]
|
||||
function a() { }
|
||||
@@ -15,9 +15,9 @@ if (true) {
|
||||
var x_1;
|
||||
if (true) {
|
||||
var x = 0; // Error
|
||||
var _a = ({ x: 0 }).x, x = _a === void 0 ? 0 : _a; // Error
|
||||
var _b = ({ x: 0 }).x, x = _b === void 0 ? 0 : _b; // Error
|
||||
var x = ({ x: 0 }).x; // Error
|
||||
var x = ({ x: 0 }).x; // Error
|
||||
var _a = { x: 0 }.x, x = _a === void 0 ? 0 : _a; // Error
|
||||
var _b = { x: 0 }.x, x = _b === void 0 ? 0 : _b; // Error
|
||||
var x = { x: 0 }.x; // Error
|
||||
var x = { x: 0 }.x; // Error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ var {public, protected} = { public: 1, protected: 2 };
|
||||
|
||||
//// [strictModeReservedWordInDestructuring.js]
|
||||
"use strict";
|
||||
var public = ([1])[0];
|
||||
var public = ({ x: 1 }).x;
|
||||
var private = ([["hello"]])[0][0];
|
||||
var public = [1][0];
|
||||
var public = { x: 1 }.x;
|
||||
var private = [["hello"]][0][0];
|
||||
var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p;
|
||||
var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected;
|
||||
|
||||
@@ -27,5 +27,5 @@ function F() {
|
||||
function as() { }
|
||||
}
|
||||
function H() {
|
||||
var as = ({ as: 1 }).as;
|
||||
var as = { as: 1 }.as;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
var tuple: [string, number];
|
||||
[...c] = tupel; // intentionally misspelled
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var { x } = new C;
|
||||
@@ -0,0 +1 @@
|
||||
var { toExponential } = 0;
|
||||
@@ -0,0 +1 @@
|
||||
function a(...{a, b}) { }
|
||||
@@ -0,0 +1 @@
|
||||
function a(...[a, b]) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
var a: any;
|
||||
var x: string;
|
||||
[x] = a;
|
||||
@@ -0,0 +1,2 @@
|
||||
var c = {};
|
||||
[...c] = ["", 0];
|
||||
@@ -0,0 +1,3 @@
|
||||
//@target: ES6
|
||||
var c = {};
|
||||
[...c] = ["", 0];
|
||||
@@ -0,0 +1,2 @@
|
||||
var c = { bogus: 0 };
|
||||
[...c] = ["", 0];
|
||||
@@ -0,0 +1,3 @@
|
||||
//@target: ES6
|
||||
var a: string, b: number;
|
||||
[...[a, b = 0]] = ["", 1];
|
||||
@@ -0,0 +1,3 @@
|
||||
//@target: ES6
|
||||
var a: string, b: number;
|
||||
[...{ 0: a = "", b }] = ["", 1];
|
||||
@@ -0,0 +1,3 @@
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...[a, b = 0]] = tuple;
|
||||
@@ -0,0 +1,3 @@
|
||||
var a: string, b: number;
|
||||
var tuple: [string, number] = ["", 1];
|
||||
[...{ 0: a = "", b }] = tuple;
|
||||
@@ -0,0 +1,2 @@
|
||||
var s: string, s2: string;
|
||||
[...[s, s2]] = ["", ""];
|
||||
@@ -0,0 +1 @@
|
||||
var [...[a, b]] = [0, 1];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user