mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Merge pull request #4598 from Microsoft/destructuringInitializers
Improved checking of destructuring with literal initializers
This commit is contained in:
commit
dcb9e1c7a5
@ -2318,8 +2318,8 @@ namespace ts {
|
||||
// Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature,
|
||||
// or otherwise the type of the string index signature.
|
||||
type = getTypeOfPropertyOfType(parentType, name.text) ||
|
||||
isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) ||
|
||||
getIndexTypeOfType(parentType, IndexKind.String);
|
||||
isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) ||
|
||||
getIndexTypeOfType(parentType, IndexKind.String);
|
||||
if (!type) {
|
||||
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name));
|
||||
return unknownType;
|
||||
@ -2406,7 +2406,7 @@ namespace ts {
|
||||
|
||||
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
|
||||
if (isBindingPattern(declaration.name)) {
|
||||
return getTypeFromBindingPattern(<BindingPattern>declaration.name);
|
||||
return getTypeFromBindingPattern(<BindingPattern>declaration.name, /*includePatternInType*/ false);
|
||||
}
|
||||
|
||||
// No type specified and nothing can be inferred
|
||||
@ -2416,48 +2416,47 @@ namespace ts {
|
||||
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
|
||||
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
|
||||
// pattern. Otherwise, it is the type any.
|
||||
function getTypeFromBindingElement(element: BindingElement): Type {
|
||||
function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type {
|
||||
if (element.initializer) {
|
||||
return getWidenedType(checkExpressionCached(element.initializer));
|
||||
}
|
||||
if (isBindingPattern(element.name)) {
|
||||
return getTypeFromBindingPattern(<BindingPattern>element.name);
|
||||
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType);
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
|
||||
// Return the type implied by an object binding pattern
|
||||
function getTypeFromObjectBindingPattern(pattern: BindingPattern): Type {
|
||||
function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type {
|
||||
let members: SymbolTable = {};
|
||||
forEach(pattern.elements, e => {
|
||||
let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0);
|
||||
let name = e.propertyName || <Identifier>e.name;
|
||||
let symbol = <TransientSymbol>createSymbol(flags, name.text);
|
||||
symbol.type = getTypeFromBindingElement(e);
|
||||
symbol.type = getTypeFromBindingElement(e, includePatternInType);
|
||||
symbol.bindingElement = e;
|
||||
members[symbol.name] = symbol;
|
||||
});
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
|
||||
let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
|
||||
if (includePatternInType) {
|
||||
result.pattern = pattern;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return the type implied by an array binding pattern
|
||||
function getTypeFromArrayBindingPattern(pattern: BindingPattern): Type {
|
||||
let hasSpreadElement: boolean = false;
|
||||
let elementTypes: Type[] = [];
|
||||
forEach(pattern.elements, e => {
|
||||
elementTypes.push(e.kind === SyntaxKind.OmittedExpression || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
|
||||
if (e.dotDotDotToken) {
|
||||
hasSpreadElement = true;
|
||||
}
|
||||
});
|
||||
if (!elementTypes.length) {
|
||||
function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type {
|
||||
let elements = pattern.elements;
|
||||
if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
|
||||
return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType;
|
||||
}
|
||||
else if (hasSpreadElement) {
|
||||
let unionOfElements = getUnionType(elementTypes);
|
||||
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.
|
||||
let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType));
|
||||
if (includePatternInType) {
|
||||
let result = createNewTupleType(elementTypes);
|
||||
result.pattern = pattern;
|
||||
return result;
|
||||
}
|
||||
return createTupleType(elementTypes);
|
||||
}
|
||||
|
||||
@ -2468,10 +2467,10 @@ namespace ts {
|
||||
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
|
||||
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
|
||||
// the parameter.
|
||||
function getTypeFromBindingPattern(pattern: BindingPattern): Type {
|
||||
function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean): Type {
|
||||
return pattern.kind === SyntaxKind.ObjectBindingPattern
|
||||
? getTypeFromObjectBindingPattern(pattern)
|
||||
: getTypeFromArrayBindingPattern(pattern);
|
||||
? getTypeFromObjectBindingPattern(pattern, includePatternInType)
|
||||
: getTypeFromArrayBindingPattern(pattern, includePatternInType);
|
||||
}
|
||||
|
||||
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
|
||||
@ -3126,7 +3125,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature {
|
||||
for (let s of signatureList) {
|
||||
for (let s of signatureList) {
|
||||
if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) {
|
||||
return s;
|
||||
}
|
||||
@ -4047,11 +4046,12 @@ namespace ts {
|
||||
|
||||
function createTupleType(elementTypes: Type[]) {
|
||||
let id = getTypeListId(elementTypes);
|
||||
let type = tupleTypes[id];
|
||||
if (!type) {
|
||||
type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes));
|
||||
type.elementTypes = elementTypes;
|
||||
}
|
||||
return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
|
||||
}
|
||||
|
||||
function createNewTupleType(elementTypes: Type[]) {
|
||||
let type = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes));
|
||||
type.elementTypes = elementTypes;
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -6616,7 +6616,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (isBindingPattern(declaration.name)) {
|
||||
return getTypeFromBindingPattern(<BindingPattern>declaration.name);
|
||||
return getTypeFromBindingPattern(<BindingPattern>declaration.name, /*includePatternInType*/ true);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@ -7012,11 +7012,13 @@ namespace ts {
|
||||
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
|
||||
}
|
||||
|
||||
function hasDefaultValue(node: BindingElement | Expression): boolean {
|
||||
return (node.kind === SyntaxKind.BindingElement && !!(<BindingElement>node).initializer) ||
|
||||
(node.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node).operatorToken.kind === SyntaxKind.EqualsToken);
|
||||
}
|
||||
|
||||
function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type {
|
||||
let elements = node.elements;
|
||||
if (!elements.length) {
|
||||
return createArrayType(undefinedType);
|
||||
}
|
||||
let hasSpreadElement = false;
|
||||
let elementTypes: Type[] = [];
|
||||
let inDestructuringPattern = isAssignmentTarget(node);
|
||||
@ -7048,12 +7050,39 @@ namespace ts {
|
||||
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
|
||||
}
|
||||
if (!hasSpreadElement) {
|
||||
// If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
|
||||
// that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
|
||||
if (inDestructuringPattern && elementTypes.length) {
|
||||
let type = createNewTupleType(elementTypes);
|
||||
type.pattern = node;
|
||||
return type;
|
||||
}
|
||||
let contextualType = getContextualType(node);
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
|
||||
return createTupleType(elementTypes);
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
|
||||
let pattern = contextualType.pattern;
|
||||
// If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
|
||||
// tuple type with the corresponding binding or assignment element types to make the lengths equal.
|
||||
if (pattern && (pattern.kind === SyntaxKind.ArrayBindingPattern || pattern.kind === SyntaxKind.ArrayLiteralExpression)) {
|
||||
let patternElements = (<BindingPattern | ArrayLiteralExpression>pattern).elements;
|
||||
for (let i = elementTypes.length; i < patternElements.length; i++) {
|
||||
let patternElement = patternElements[i];
|
||||
if (hasDefaultValue(patternElement)) {
|
||||
elementTypes.push((<TupleType>contextualType).elementTypes[i]);
|
||||
}
|
||||
else {
|
||||
if (patternElement.kind !== SyntaxKind.OmittedExpression) {
|
||||
error(patternElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
|
||||
}
|
||||
elementTypes.push(unknownType);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (elementTypes.length) {
|
||||
return createTupleType(elementTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return createArrayType(getUnionType(elementTypes));
|
||||
return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType)
|
||||
}
|
||||
|
||||
function isNumericName(name: DeclarationName): boolean {
|
||||
@ -7120,6 +7149,9 @@ namespace ts {
|
||||
let propertiesTable: SymbolTable = {};
|
||||
let propertiesArray: Symbol[] = [];
|
||||
let contextualType = getContextualType(node);
|
||||
let contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
||||
(contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression);
|
||||
let inDestructuringPattern = isAssignmentTarget(node);
|
||||
let typeFlags: TypeFlags = 0;
|
||||
|
||||
for (let memberDecl of node.properties) {
|
||||
@ -7140,6 +7172,25 @@ namespace ts {
|
||||
}
|
||||
typeFlags |= type.flags;
|
||||
let prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
|
||||
if (inDestructuringPattern) {
|
||||
// If object literal is an assignment pattern and if the assignment pattern specifies a default value
|
||||
// for the property, make the property optional.
|
||||
if (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((<PropertyAssignment>memberDecl).initializer)) {
|
||||
prop.flags |= SymbolFlags.Optional;
|
||||
}
|
||||
}
|
||||
else if (contextualTypeHasPattern) {
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, and if the
|
||||
// binding pattern specifies a default value for the property, make the property optional.
|
||||
let impliedProp = getPropertyOfType(contextualType, member.name);
|
||||
if (impliedProp) {
|
||||
prop.flags |= impliedProp.flags & SymbolFlags.Optional;
|
||||
}
|
||||
else if (!compilerOptions.suppressExcessPropertyErrors) {
|
||||
error(memberDecl.name, Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
|
||||
symbolToString(member), typeToString(contextualType));
|
||||
}
|
||||
}
|
||||
prop.declarations = member.declarations;
|
||||
prop.parent = member.parent;
|
||||
if (member.valueDeclaration) {
|
||||
@ -7166,11 +7217,29 @@ namespace ts {
|
||||
propertiesArray.push(member);
|
||||
}
|
||||
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, augment the result
|
||||
// type with those properties for which the binding pattern specifies a default value.
|
||||
if (contextualTypeHasPattern) {
|
||||
for (let prop of getPropertiesOfType(contextualType)) {
|
||||
if (!hasProperty(propertiesTable, prop.name)) {
|
||||
if (!(prop.flags & SymbolFlags.Optional)) {
|
||||
error(prop.valueDeclaration || (<TransientSymbol>prop).bindingElement,
|
||||
Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
|
||||
}
|
||||
propertiesTable[prop.name] = prop;
|
||||
propertiesArray.push(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let stringIndexType = getIndexType(IndexKind.String);
|
||||
let numberIndexType = getIndexType(IndexKind.Number);
|
||||
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral;
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
|
||||
if (inDestructuringPattern) {
|
||||
result.pattern = node;
|
||||
}
|
||||
return result;
|
||||
|
||||
function getIndexType(kind: IndexKind) {
|
||||
|
||||
@ -415,6 +415,7 @@ namespace ts {
|
||||
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
|
||||
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
|
||||
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
|
||||
Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
|
||||
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
|
||||
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
|
||||
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
|
||||
|
||||
@ -1649,6 +1649,10 @@
|
||||
"category": "Error",
|
||||
"code": 2524
|
||||
},
|
||||
"Initializer provides no value for this binding element and the binding element has no default value.": {
|
||||
"category": "Error",
|
||||
"code": 2525
|
||||
},
|
||||
"JSX element attributes type '{0}' must be an object type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
|
||||
@ -1715,6 +1715,7 @@ namespace ts {
|
||||
resolvedExports?: SymbolTable; // Resolved exports of module
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
|
||||
bindingElement?: BindingElement; // Binding element associated with property symbol
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@ -1812,11 +1813,14 @@ namespace ts {
|
||||
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
|
||||
}
|
||||
|
||||
export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
|
||||
// Properties common to all types
|
||||
export interface Type {
|
||||
flags: TypeFlags; // Flags
|
||||
/* @internal */ id: number; // Unique ID
|
||||
symbol?: Symbol; // Symbol associated with type (if any)
|
||||
flags: TypeFlags; // Flags
|
||||
/* @internal */ id: number; // Unique ID
|
||||
symbol?: Symbol; // Symbol associated with type (if any)
|
||||
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@ -1865,8 +1869,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface TupleType extends ObjectType {
|
||||
elementTypes: Type[]; // Element types
|
||||
baseArrayType: TypeReference; // Array<T> where T is best common type of element types
|
||||
elementTypes: Type[]; // Element types
|
||||
}
|
||||
|
||||
export interface UnionOrIntersectionType extends Type {
|
||||
|
||||
@ -100,12 +100,12 @@ var p8 = ({ a = 1 }) => { };
|
||||
>1 : number
|
||||
|
||||
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
|
||||
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>a : any
|
||||
>b : number
|
||||
>1 : number
|
||||
>{ b: 1 } : { b: number; }
|
||||
>{ b: 1 } : { b?: number; }
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
|
||||
@ -21,8 +21,8 @@ function h1(_a) {
|
||||
|
||||
//// [declarationEmitDestructuring2.d.ts]
|
||||
declare function f({x, y: [a, b, c, d]}?: {
|
||||
x: number;
|
||||
y: [number, number, number, number];
|
||||
x?: number;
|
||||
y?: [number, number, number, number];
|
||||
}): void;
|
||||
declare function g([a, b, c, d]?: [number, number, number, number]): void;
|
||||
declare function h([a, [b], [[c]], {x, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], {
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/declarationEmitDestructuring4.ts(9,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuring4.ts (1 errors) ====
|
||||
// For an array binding pattern with empty elements,
|
||||
// we will not make any modification and will emit
|
||||
// the similar binding pattern users' have written
|
||||
function baz([]) { }
|
||||
function baz1([] = [1,2,3]) { }
|
||||
function baz2([[]] = [[1,2,3]]) { }
|
||||
|
||||
function baz3({}) { }
|
||||
function baz4({} = { x: 10 }) { }
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuring4.ts ===
|
||||
// For an array binding pattern with empty elements,
|
||||
// we will not make any modification and will emit
|
||||
// the similar binding pattern users' have written
|
||||
function baz([]) { }
|
||||
>baz : Symbol(baz, Decl(declarationEmitDestructuring4.ts, 0, 0))
|
||||
|
||||
function baz1([] = [1,2,3]) { }
|
||||
>baz1 : Symbol(baz1, Decl(declarationEmitDestructuring4.ts, 3, 20))
|
||||
|
||||
function baz2([[]] = [[1,2,3]]) { }
|
||||
>baz2 : Symbol(baz2, Decl(declarationEmitDestructuring4.ts, 4, 31))
|
||||
|
||||
function baz3({}) { }
|
||||
>baz3 : Symbol(baz3, Decl(declarationEmitDestructuring4.ts, 5, 35))
|
||||
|
||||
function baz4({} = { x: 10 }) { }
|
||||
>baz4 : Symbol(baz4, Decl(declarationEmitDestructuring4.ts, 7, 21))
|
||||
>x : Symbol(x, Decl(declarationEmitDestructuring4.ts, 8, 20))
|
||||
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuring4.ts ===
|
||||
// For an array binding pattern with empty elements,
|
||||
// we will not make any modification and will emit
|
||||
// the similar binding pattern users' have written
|
||||
function baz([]) { }
|
||||
>baz : ([]: any[]) => void
|
||||
|
||||
function baz1([] = [1,2,3]) { }
|
||||
>baz1 : ([]?: number[]) => void
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
function baz2([[]] = [[1,2,3]]) { }
|
||||
>baz2 : ([[]]?: [number[]]) => void
|
||||
>[[1,2,3]] : [number[]]
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
function baz3({}) { }
|
||||
>baz3 : ({}: {}) => void
|
||||
|
||||
function baz4({} = { x: 10 }) { }
|
||||
>baz4 : ({}?: { x: number; }) => void
|
||||
>{ x: 10 } : { x: number; }
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts (3 errors) ====
|
||||
var [x10, [y10, [z10]]] = [1, ["hello", [true]]];
|
||||
|
||||
var [x11 = 0, y11 = ""] = [1, "hello"];
|
||||
var [a11, b11, c11] = [];
|
||||
~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
|
||||
var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]];
|
||||
|
||||
var [x13, y13] = [1, "hello"];
|
||||
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts ===
|
||||
var [x10, [y10, [z10]]] = [1, ["hello", [true]]];
|
||||
>x10 : Symbol(x10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 5))
|
||||
>y10 : Symbol(y10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 11))
|
||||
>z10 : Symbol(z10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 17))
|
||||
|
||||
var [x11 = 0, y11 = ""] = [1, "hello"];
|
||||
>x11 : Symbol(x11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 5))
|
||||
>y11 : Symbol(y11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 13))
|
||||
|
||||
var [a11, b11, c11] = [];
|
||||
>a11 : Symbol(a11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 5))
|
||||
>b11 : Symbol(b11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 9))
|
||||
>c11 : Symbol(c11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 14))
|
||||
|
||||
var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]];
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 5))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 10))
|
||||
>x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 15))
|
||||
>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91))
|
||||
>c2 : Symbol(c2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 20))
|
||||
>x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 41))
|
||||
>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 50))
|
||||
>x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 83))
|
||||
>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91))
|
||||
|
||||
var [x13, y13] = [1, "hello"];
|
||||
>x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5))
|
||||
>y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9))
|
||||
|
||||
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];
|
||||
>a3 : Symbol(a3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 5))
|
||||
>b3 : Symbol(b3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 8))
|
||||
>x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5))
|
||||
>y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9))
|
||||
>x : Symbol(x, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 29))
|
||||
>x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5))
|
||||
>y : Symbol(y, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 37))
|
||||
>y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9))
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts ===
|
||||
var [x10, [y10, [z10]]] = [1, ["hello", [true]]];
|
||||
>x10 : number
|
||||
>y10 : string
|
||||
>z10 : boolean
|
||||
>[1, ["hello", [true]]] : [number, [string, [boolean]]]
|
||||
>1 : number
|
||||
>["hello", [true]] : [string, [boolean]]
|
||||
>"hello" : string
|
||||
>[true] : [boolean]
|
||||
>true : boolean
|
||||
|
||||
var [x11 = 0, y11 = ""] = [1, "hello"];
|
||||
>x11 : number
|
||||
>0 : number
|
||||
>y11 : string
|
||||
>"" : string
|
||||
>[1, "hello"] : [number, string]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
var [a11, b11, c11] = [];
|
||||
>a11 : any
|
||||
>b11 : any
|
||||
>c11 : any
|
||||
>[] : undefined[]
|
||||
|
||||
var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]];
|
||||
>a2 : number
|
||||
>b2 : string
|
||||
>x12 : number
|
||||
>y12 : any
|
||||
>c2 : boolean
|
||||
>["abc", { x12: 10, y12: false }] : [string, { x12: number; y12: boolean; }]
|
||||
>"abc" : string
|
||||
>{ x12: 10, y12: false } : { x12: number; y12: boolean; }
|
||||
>x12 : number
|
||||
>10 : number
|
||||
>y12 : boolean
|
||||
>false : boolean
|
||||
>[1, ["hello", { x12: 5, y12: true }]] : [number, [string, { x12: number; y12: boolean; }]]
|
||||
>1 : number
|
||||
>["hello", { x12: 5, y12: true }] : [string, { x12: number; y12: boolean; }]
|
||||
>"hello" : string
|
||||
>{ x12: 5, y12: true } : { x12: number; y12: boolean; }
|
||||
>x12 : number
|
||||
>5 : number
|
||||
>y12 : boolean
|
||||
>true : boolean
|
||||
|
||||
var [x13, y13] = [1, "hello"];
|
||||
>x13 : number
|
||||
>y13 : string
|
||||
>[1, "hello"] : [number, string]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];
|
||||
>a3 : (number | string)[]
|
||||
>b3 : { x: number; y: string; }
|
||||
>[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }]
|
||||
>[x13, y13] : (number | string)[]
|
||||
>x13 : number
|
||||
>y13 : string
|
||||
>{ x: x13, y: y13 } : { x: number; y: string; }
|
||||
>x : number
|
||||
>x13 : number
|
||||
>y : string
|
||||
>y13 : string
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts (6 errors) ====
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
|
||||
var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } };
|
||||
|
||||
function f15() {
|
||||
var a4 = "hello";
|
||||
var b4 = 1;
|
||||
var c4 = true;
|
||||
return { a4, b4, c4 };
|
||||
}
|
||||
var { a4, b4, c4 } = f15();
|
||||
|
||||
module m {
|
||||
export var { a4, b4, c4 } = f15();
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts ===
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
>x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 11))
|
||||
>y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 17))
|
||||
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
>x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 5))
|
||||
>x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 14))
|
||||
>y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 21))
|
||||
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
>y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 5))
|
||||
>x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 14))
|
||||
>y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 21))
|
||||
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 5))
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 9))
|
||||
>x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 18))
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 25))
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18))
|
||||
>a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 5))
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18))
|
||||
>y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 25))
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25))
|
||||
>b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 5))
|
||||
>x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 18))
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25))
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 5))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 13))
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33))
|
||||
|
||||
var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } };
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46))
|
||||
>x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 5))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57))
|
||||
>y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 18))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74))
|
||||
>z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 31))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74))
|
||||
|
||||
function f15() {
|
||||
>f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89))
|
||||
|
||||
var a4 = "hello";
|
||||
>a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 12, 7))
|
||||
|
||||
var b4 = 1;
|
||||
>b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 13, 7))
|
||||
|
||||
var c4 = true;
|
||||
>c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 14, 7))
|
||||
|
||||
return { a4, b4, c4 };
|
||||
>a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 12))
|
||||
>b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 16))
|
||||
>c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 20))
|
||||
}
|
||||
var { a4, b4, c4 } = f15();
|
||||
>a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 5))
|
||||
>b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 9))
|
||||
>c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 13))
|
||||
>f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89))
|
||||
|
||||
module m {
|
||||
>m : Symbol(m, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 27))
|
||||
|
||||
export var { a4, b4, c4 } = f15();
|
||||
>a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 16))
|
||||
>b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 20))
|
||||
>c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 24))
|
||||
>f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89))
|
||||
}
|
||||
@ -1,122 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts ===
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
>{ x: 5, y: "hello" } : { x: number; y: string; }
|
||||
>x : number
|
||||
>5 : number
|
||||
>y : string
|
||||
>"hello" : string
|
||||
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
>x4 : number
|
||||
>{ x4: 5, y4: "hello" } : { x4: number; y4: string; }
|
||||
>x4 : number
|
||||
>5 : number
|
||||
>y4 : string
|
||||
>"hello" : string
|
||||
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
>y5 : string
|
||||
>{ x5: 5, y5: "hello" } : { x5: number; y5: string; }
|
||||
>x5 : number
|
||||
>5 : number
|
||||
>y5 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>x6 : number
|
||||
>y6 : string
|
||||
>{ x6: 5, y6: "hello" } : { x6: number; y6: string; }
|
||||
>x6 : number
|
||||
>5 : number
|
||||
>y6 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : any
|
||||
>a1 : number
|
||||
>{ x7: 5, y7: "hello" } : { x7: number; y7: string; }
|
||||
>x7 : number
|
||||
>5 : number
|
||||
>y7 : string
|
||||
>"hello" : string
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : any
|
||||
>b1 : string
|
||||
>{ x8: 5, y8: "hello" } : { x8: number; y8: string; }
|
||||
>x8 : number
|
||||
>5 : number
|
||||
>y8 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : any
|
||||
>a2 : number
|
||||
>y9 : any
|
||||
>b2 : string
|
||||
>{ x9: 5, y9: "hello" } : { x9: number; y9: string; }
|
||||
>x9 : number
|
||||
>5 : number
|
||||
>y9 : string
|
||||
>"hello" : string
|
||||
|
||||
var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } };
|
||||
>a : any
|
||||
>x11 : number
|
||||
>b : any
|
||||
>a : any
|
||||
>y11 : string
|
||||
>b : any
|
||||
>a : any
|
||||
>z11 : boolean
|
||||
>{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; }
|
||||
>a : number
|
||||
>1 : number
|
||||
>b : { a: string; b: { a: boolean; }; }
|
||||
>{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; }
|
||||
>a : string
|
||||
>"hello" : string
|
||||
>b : { a: boolean; }
|
||||
>{ a: true } : { a: boolean; }
|
||||
>a : boolean
|
||||
>true : boolean
|
||||
|
||||
function f15() {
|
||||
>f15 : () => { a4: string; b4: number; c4: boolean; }
|
||||
|
||||
var a4 = "hello";
|
||||
>a4 : string
|
||||
>"hello" : string
|
||||
|
||||
var b4 = 1;
|
||||
>b4 : number
|
||||
>1 : number
|
||||
|
||||
var c4 = true;
|
||||
>c4 : boolean
|
||||
>true : boolean
|
||||
|
||||
return { a4, b4, c4 };
|
||||
>{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; }
|
||||
>a4 : string
|
||||
>b4 : number
|
||||
>c4 : boolean
|
||||
}
|
||||
var { a4, b4, c4 } = f15();
|
||||
>a4 : string
|
||||
>b4 : number
|
||||
>c4 : boolean
|
||||
>f15() : { a4: string; b4: number; c4: boolean; }
|
||||
>f15 : () => { a4: string; b4: number; c4: boolean; }
|
||||
|
||||
module m {
|
||||
>m : typeof m
|
||||
|
||||
export var { a4, b4, c4 } = f15();
|
||||
>a4 : string
|
||||
>b4 : number
|
||||
>c4 : boolean
|
||||
>f15() : { a4: string; b4: number; c4: boolean; }
|
||||
>f15 : () => { a4: string; b4: number; c4: boolean; }
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts (6 errors) ====
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
@ -1,42 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts ===
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
>x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 11))
|
||||
>y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 17))
|
||||
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
>x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 5))
|
||||
>x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 14))
|
||||
>y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 21))
|
||||
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
>y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 5))
|
||||
>x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 14))
|
||||
>y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 21))
|
||||
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 5))
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 9))
|
||||
>x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 18))
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 25))
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18))
|
||||
>a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 5))
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18))
|
||||
>y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 25))
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25))
|
||||
>b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 5))
|
||||
>x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 18))
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25))
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 5))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 13))
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33))
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts ===
|
||||
|
||||
var { } = { x: 5, y: "hello" };
|
||||
>{ x: 5, y: "hello" } : { x: number; y: string; }
|
||||
>x : number
|
||||
>5 : number
|
||||
>y : string
|
||||
>"hello" : string
|
||||
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
>x4 : number
|
||||
>{ x4: 5, y4: "hello" } : { x4: number; y4: string; }
|
||||
>x4 : number
|
||||
>5 : number
|
||||
>y4 : string
|
||||
>"hello" : string
|
||||
|
||||
var { y5 } = { x5: 5, y5: "hello" };
|
||||
>y5 : string
|
||||
>{ x5: 5, y5: "hello" } : { x5: number; y5: string; }
|
||||
>x5 : number
|
||||
>5 : number
|
||||
>y5 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>x6 : number
|
||||
>y6 : string
|
||||
>{ x6: 5, y6: "hello" } : { x6: number; y6: string; }
|
||||
>x6 : number
|
||||
>5 : number
|
||||
>y6 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : any
|
||||
>a1 : number
|
||||
>{ x7: 5, y7: "hello" } : { x7: number; y7: string; }
|
||||
>x7 : number
|
||||
>5 : number
|
||||
>y7 : string
|
||||
>"hello" : string
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : any
|
||||
>b1 : string
|
||||
>{ x8: 5, y8: "hello" } : { x8: number; y8: string; }
|
||||
>x8 : number
|
||||
>5 : number
|
||||
>y8 : string
|
||||
>"hello" : string
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : any
|
||||
>a2 : number
|
||||
>y9 : any
|
||||
>b2 : string
|
||||
>{ x9: 5, y9: "hello" } : { x9: number; y9: string; }
|
||||
>x9 : number
|
||||
>5 : number
|
||||
>y9 : string
|
||||
>"hello" : string
|
||||
|
||||
@ -1,11 +1,20 @@
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2459: Type '{}' has no property 'a' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2459: Type '{}' has no property 'b' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'.
|
||||
@ -18,15 +27,15 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6):
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (13 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (22 errors) ====
|
||||
function f0() {
|
||||
var [] = [1, "hello"];
|
||||
var [x] = [1, "hello"];
|
||||
var [x, y] = [1, "hello"];
|
||||
var [x, y, z] = [1, "hello"]; // Error
|
||||
var [x, y, z] = [1, "hello"];
|
||||
~
|
||||
!!! error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'.
|
||||
var [,, z] = [0, 1, 2];
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [,, x] = [0, 1, 2];
|
||||
var x: number;
|
||||
var y: string;
|
||||
}
|
||||
@ -42,14 +51,26 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" };
|
||||
var { x } = { x: 5, y: "hello" };
|
||||
var { y } = { x: 5, y: "hello" };
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
var { y } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
var { x, y } = { x: 5, y: "hello" };
|
||||
var x: number;
|
||||
var y: string;
|
||||
var { x: a } = { x: 5, y: "hello" };
|
||||
var { y: b } = { x: 5, y: "hello" };
|
||||
var { x: a } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
var { y: b } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
var { x: a, y: b } = { x: 5, y: "hello" };
|
||||
var a: number;
|
||||
var b: string;
|
||||
@ -85,11 +106,17 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
|
||||
|
||||
function f8() {
|
||||
var [a, b, c] = []; // Ok, [] is an array
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [d, e, f] = [1]; // Error, [1] is a tuple
|
||||
~
|
||||
!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
}
|
||||
|
||||
function f9() {
|
||||
@ -105,9 +132,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
|
||||
function f10() {
|
||||
var { a, b } = {}; // Error
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'a' and no string index signature.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'b' and no string index signature.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var { a, b } = []; // Error
|
||||
~
|
||||
!!! error TS2459: Type 'undefined[]' has no property 'a' and no string index signature.
|
||||
|
||||
@ -3,8 +3,8 @@ function f0() {
|
||||
var [] = [1, "hello"];
|
||||
var [x] = [1, "hello"];
|
||||
var [x, y] = [1, "hello"];
|
||||
var [x, y, z] = [1, "hello"]; // Error
|
||||
var [,, z] = [0, 1, 2];
|
||||
var [x, y, z] = [1, "hello"];
|
||||
var [,, x] = [0, 1, 2];
|
||||
var x: number;
|
||||
var y: string;
|
||||
}
|
||||
@ -20,14 +20,14 @@ function f1() {
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" };
|
||||
var { x } = { x: 5, y: "hello" };
|
||||
var { y } = { x: 5, y: "hello" };
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x, y } = { x: 5, y: "hello" };
|
||||
var x: number;
|
||||
var y: string;
|
||||
var { x: a } = { x: 5, y: "hello" };
|
||||
var { y: b } = { x: 5, y: "hello" };
|
||||
var { x: a } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y: b } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x: a, y: b } = { x: 5, y: "hello" };
|
||||
var a: number;
|
||||
var b: string;
|
||||
@ -185,8 +185,8 @@ function f0() {
|
||||
var _a = [1, "hello"];
|
||||
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];
|
||||
var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2];
|
||||
var _d = [0, 1, 2], x = _d[2];
|
||||
var x;
|
||||
var y;
|
||||
}
|
||||
@ -200,14 +200,14 @@ function f1() {
|
||||
var z;
|
||||
}
|
||||
function f2() {
|
||||
var _a = { x: 5, y: "hello" };
|
||||
var x = { x: 5, y: "hello" }.x;
|
||||
var y = { x: 5, y: "hello" }.y;
|
||||
var _a = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var x = { x: 5, y: "hello" }.x; // Error, no y in target
|
||||
var y = { x: 5, y: "hello" }.y; // Error, no x in target
|
||||
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; // Error, no y in target
|
||||
var b = { x: 5, y: "hello" }.y; // Error, no x in target
|
||||
var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y;
|
||||
var a;
|
||||
var b;
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts (3 errors) ====
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
|
||||
function foo() {
|
||||
return [1, 2, 3];
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
var [...b8] = foo();
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
var [c0, c1] = [...temp];
|
||||
var [c2] = [];
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
var [, c7] = [1, 2, 3];
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
|
||||
|
||||
@ -1,105 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts ===
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
>a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 5))
|
||||
>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 8))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 5))
|
||||
>a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 16))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
>b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 5))
|
||||
>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 8))
|
||||
>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 12))
|
||||
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
>b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 5))
|
||||
>b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 8))
|
||||
>b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 12))
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62))
|
||||
|
||||
return [1, 2, 3];
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
>b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 5))
|
||||
>b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 8))
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62))
|
||||
|
||||
var [...b8] = foo();
|
||||
>b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 37, 5))
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62))
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3))
|
||||
|
||||
var [c0, c1] = [...temp];
|
||||
>c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 5))
|
||||
>c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 8))
|
||||
>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3))
|
||||
|
||||
var [c2] = [];
|
||||
>c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 42, 5))
|
||||
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
>c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 7))
|
||||
>c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 17))
|
||||
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
>c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 6))
|
||||
>c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 10))
|
||||
|
||||
var [, c7] = [1, 2, 3];
|
||||
>c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 45, 6))
|
||||
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
>c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 46, 8))
|
||||
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
>c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 47, 8))
|
||||
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
>c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 48, 8))
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 5))
|
||||
>c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 9))
|
||||
>c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 14))
|
||||
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
>c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 5))
|
||||
>c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 9))
|
||||
>c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 14))
|
||||
|
||||
|
||||
@ -1,177 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts ===
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
>a0 : any
|
||||
>a1 : any
|
||||
>undefined : undefined
|
||||
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
>a2 : boolean
|
||||
>false : boolean
|
||||
>a3 : number
|
||||
>1 : number
|
||||
>undefined : undefined
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
>b0 : number
|
||||
>b1 : number
|
||||
>b2 : number
|
||||
>[2, 3, 4] : [number, number, number]
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
>b3 : number
|
||||
>b4 : number
|
||||
>b5 : string
|
||||
>[1, 2, "string"] : [number, number, string]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
function foo() {
|
||||
>foo : () => number[]
|
||||
|
||||
return [1, 2, 3];
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
>b6 : number
|
||||
>b7 : number
|
||||
>foo() : number[]
|
||||
>foo : () => number[]
|
||||
|
||||
var [...b8] = foo();
|
||||
>b8 : number[]
|
||||
>foo() : number[]
|
||||
>foo : () => number[]
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
>temp : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
var [c0, c1] = [...temp];
|
||||
>c0 : number
|
||||
>c1 : number
|
||||
>[...temp] : number[]
|
||||
>...temp : number
|
||||
>temp : number[]
|
||||
|
||||
var [c2] = [];
|
||||
>c2 : any
|
||||
>[] : undefined[]
|
||||
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
>c3 : any
|
||||
>c4 : any
|
||||
>[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]]
|
||||
>[[]] : [undefined[]]
|
||||
>[] : undefined[]
|
||||
>[[[[]]]] : [[[undefined[]]]]
|
||||
>[[[]]] : [[undefined[]]]
|
||||
>[[]] : [undefined[]]
|
||||
>[] : undefined[]
|
||||
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
>c5 : string | number
|
||||
>c6 : boolean
|
||||
>[[1], true] : [[number], boolean]
|
||||
>[1] : [number]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
|
||||
var [, c7] = [1, 2, 3];
|
||||
> : undefined
|
||||
>c7 : number
|
||||
>[1, 2, 3] : [number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c8 : number
|
||||
>[1, 2, 3, 4] : [number, number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c9 : number
|
||||
>[1, 2, 3, 4] : [number, number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c10 : (number | string)[]
|
||||
>[1, 2, 3, 4, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
>"hello" : string
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : number | string
|
||||
>c12 : number | string
|
||||
>c13 : (number | string)[]
|
||||
>[1, 2, "string"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
>c14 : number
|
||||
>c15 : number
|
||||
>c16 : string
|
||||
>[1, 2, "string"] : [number, number, string]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(44,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts (3 errors) ====
|
||||
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
|
||||
function foo() {
|
||||
return [1, 2, 3];
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
var [...b8] = foo();
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
var [c0, c1] = [...temp];
|
||||
var [c2] = [];
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
var [, c7] = [1, 2, 3];
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
@ -1,105 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts ===
|
||||
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
>a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 5))
|
||||
>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 8))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 5))
|
||||
>a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 16))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
>b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 5))
|
||||
>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 8))
|
||||
>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 12))
|
||||
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
>b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 5))
|
||||
>b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 8))
|
||||
>b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 12))
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62))
|
||||
|
||||
return [1, 2, 3];
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
>b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 5))
|
||||
>b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 8))
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62))
|
||||
|
||||
var [...b8] = foo();
|
||||
>b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 38, 5))
|
||||
>foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62))
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3))
|
||||
|
||||
var [c0, c1] = [...temp];
|
||||
>c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 5))
|
||||
>c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 8))
|
||||
>temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3))
|
||||
|
||||
var [c2] = [];
|
||||
>c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 43, 5))
|
||||
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
>c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 7))
|
||||
>c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 17))
|
||||
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
>c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 6))
|
||||
>c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 10))
|
||||
|
||||
var [, c7] = [1, 2, 3];
|
||||
>c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 46, 6))
|
||||
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
>c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 47, 8))
|
||||
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
>c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 48, 8))
|
||||
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
>c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 49, 8))
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 5))
|
||||
>c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 9))
|
||||
>c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 14))
|
||||
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
>c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 5))
|
||||
>c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 9))
|
||||
>c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 14))
|
||||
|
||||
@ -1,177 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts ===
|
||||
|
||||
/* AssignmentPattern:
|
||||
* ObjectAssignmentPattern
|
||||
* ArrayAssignmentPattern
|
||||
* ArrayAssignmentPattern:
|
||||
* [Elision<opt> AssignmentRestElementopt ]
|
||||
* [AssignmentElementList]
|
||||
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
|
||||
* AssignmentElementList:
|
||||
* Elision<opt> AssignmentElement
|
||||
* AssignmentElementList, Elisionopt AssignmentElement
|
||||
* AssignmentElement:
|
||||
* LeftHandSideExpression Initialiseropt
|
||||
* AssignmentPattern Initialiseropt
|
||||
* AssignmentRestElement:
|
||||
* ... LeftHandSideExpression
|
||||
*/
|
||||
|
||||
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
|
||||
// An expression of type S is considered assignable to an assignment target V if one of the following is true
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is the type Any, or
|
||||
|
||||
var [a0, a1]: any = undefined;
|
||||
>a0 : any
|
||||
>a1 : any
|
||||
>undefined : undefined
|
||||
|
||||
var [a2 = false, a3 = 1]: any = undefined;
|
||||
>a2 : boolean
|
||||
>false : boolean
|
||||
>a3 : number
|
||||
>1 : number
|
||||
>undefined : undefined
|
||||
|
||||
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
||||
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
||||
// where N is the numeric index of E in the array assignment pattern, or
|
||||
var [b0, b1, b2] = [2, 3, 4];
|
||||
>b0 : number
|
||||
>b1 : number
|
||||
>b2 : number
|
||||
>[2, 3, 4] : [number, number, number]
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];
|
||||
>b3 : number
|
||||
>b4 : number
|
||||
>b5 : string
|
||||
>[1, 2, "string"] : [number, number, string]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
function foo() {
|
||||
>foo : () => number[]
|
||||
|
||||
return [1, 2, 3];
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
}
|
||||
|
||||
var [b6, b7] = foo();
|
||||
>b6 : number
|
||||
>b7 : number
|
||||
>foo() : number[]
|
||||
>foo : () => number[]
|
||||
|
||||
var [...b8] = foo();
|
||||
>b8 : number[]
|
||||
>foo() : number[]
|
||||
>foo : () => number[]
|
||||
|
||||
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
||||
var temp = [1,2,3]
|
||||
>temp : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
var [c0, c1] = [...temp];
|
||||
>c0 : number
|
||||
>c1 : number
|
||||
>[...temp] : number[]
|
||||
>...temp : number
|
||||
>temp : number[]
|
||||
|
||||
var [c2] = [];
|
||||
>c2 : any
|
||||
>[] : undefined[]
|
||||
|
||||
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
|
||||
>c3 : any
|
||||
>c4 : any
|
||||
>[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]]
|
||||
>[[]] : [undefined[]]
|
||||
>[] : undefined[]
|
||||
>[[[[]]]] : [[[undefined[]]]]
|
||||
>[[[]]] : [[undefined[]]]
|
||||
>[[]] : [undefined[]]
|
||||
>[] : undefined[]
|
||||
|
||||
var [[c5], c6]: [[string|number], boolean] = [[1], true];
|
||||
>c5 : string | number
|
||||
>c6 : boolean
|
||||
>[[1], true] : [[number], boolean]
|
||||
>[1] : [number]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
|
||||
var [, c7] = [1, 2, 3];
|
||||
> : undefined
|
||||
>c7 : number
|
||||
>[1, 2, 3] : [number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
var [,,, c8] = [1, 2, 3, 4];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c8 : number
|
||||
>[1, 2, 3, 4] : [number, number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [,,, c9] = [1, 2, 3, 4];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c9 : number
|
||||
>[1, 2, 3, 4] : [number, number, number, number]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
|
||||
var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c10 : (number | string)[]
|
||||
>[1, 2, 3, 4, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>4 : number
|
||||
>"hello" : string
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : number | string
|
||||
>c12 : number | string
|
||||
>c13 : (number | string)[]
|
||||
>[1, 2, "string"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
var [c14, c15, c16] = [1, 2, "string"];
|
||||
>c14 : number
|
||||
>c15 : number
|
||||
>c16 : string
|
||||
>[1, 2, "string"] : [number, number, string]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type.
|
||||
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'.
|
||||
Types of property '1' are incompatible.
|
||||
@ -18,9 +18,9 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss
|
||||
// S is the type Any, or
|
||||
var [[a0], [[a1]]] = [] // Error
|
||||
~~~~
|
||||
!!! error TS2461: Type 'undefined' is not an array type.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~~~~
|
||||
!!! error TS2461: Type 'undefined' is not an array type.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var [[a2], [[a3]]] = undefined // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2461: Type 'undefined' is not an array type.
|
||||
|
||||
@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } };
|
||||
>{ b21: "string" } : { b21: string; }
|
||||
>b21 : string
|
||||
>"string" : string
|
||||
>{ b2: { b21: "world" } } : { b2: { b21: string; }; }
|
||||
>{ b2: { b21: "world" } } : { b2?: { b21: string; }; }
|
||||
>b2 : { b21: string; }
|
||||
>{ b21: "world" } : { b21: string; }
|
||||
>b21 : string
|
||||
|
||||
@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } };
|
||||
>{ b21: "string" } : { b21: string; }
|
||||
>b21 : string
|
||||
>"string" : string
|
||||
>{ b2: { b21: "world" } } : { b2: { b21: string; }; }
|
||||
>{ b2: { b21: "world" } } : { b2?: { b21: string; }; }
|
||||
>b2 : { b21: string; }
|
||||
>{ b21: "world" } : { b21: string; }
|
||||
>b21 : string
|
||||
|
||||
@ -3,14 +3,18 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs
|
||||
Type '{ i: number; }' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,5): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,11): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,24): error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,7): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,15): error TS1005: ':' expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(10,12): error TS1005: ':' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (13 errors) ====
|
||||
// Error
|
||||
var {h?} = { h?: 1 };
|
||||
~
|
||||
@ -26,11 +30,19 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs
|
||||
!!! error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature.
|
||||
var { f2: {f21} = { f212: "string" } }: any = undefined;
|
||||
~~~
|
||||
!!! error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature.
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'.
|
||||
var { ...d1 } = {
|
||||
~~~
|
||||
!!! error TS1180: Property destructuring pattern expected.
|
||||
a: 1, b: 1, d1: 9, e: 10
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'.
|
||||
}
|
||||
var {1} = { 1 };
|
||||
~
|
||||
|
||||
@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } };
|
||||
>{ b11: "string" } : { b11: string; }
|
||||
>b11 : string
|
||||
>"string" : string
|
||||
>{ b1: { b11: "world" } } : { b1: { b11: string; }; }
|
||||
>{ b1: { b11: "world" } } : { b1?: { b11: string; }; }
|
||||
>b1 : { b11: string; }
|
||||
>{ b11: "world" } : { b11: string; }
|
||||
>b11 : string
|
||||
@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
>f4 : number
|
||||
>f5 : number
|
||||
> : undefined
|
||||
>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; }
|
||||
>f : [number, number, { f3: number; f5: number; }]
|
||||
>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }]
|
||||
>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; }
|
||||
>f : [number, number, { f3: number; f5: number; }, any]
|
||||
>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>{ f3: 4, f5: 0 } : { f3: number; f5: number; }
|
||||
|
||||
@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } };
|
||||
>{ b11: "string" } : { b11: string; }
|
||||
>b11 : string
|
||||
>"string" : string
|
||||
>{ b1: { b11: "world" } } : { b1: { b11: string; }; }
|
||||
>{ b1: { b11: "world" } } : { b1?: { b11: string; }; }
|
||||
>b1 : { b11: string; }
|
||||
>{ b11: "world" } : { b11: string; }
|
||||
>b11 : string
|
||||
@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
>f4 : number
|
||||
>f5 : number
|
||||
> : undefined
|
||||
>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; }
|
||||
>f : [number, number, { f3: number; f5: number; }]
|
||||
>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }]
|
||||
>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; }
|
||||
>f : [number, number, { f3: number; f5: number; }, any]
|
||||
>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>{ f3: 4, f5: 0 } : { f3: number; f5: number; }
|
||||
|
||||
@ -0,0 +1,147 @@
|
||||
//// [destructuringWithLiteralInitializers.ts]
|
||||
// (arg: { x: any, y: any }) => void
|
||||
function f1({ x, y }) { }
|
||||
f1({ x: 1, y: 1 });
|
||||
|
||||
// (arg: { x: any, y?: number }) => void
|
||||
function f2({ x, y = 0 }) { }
|
||||
f2({ x: 1 });
|
||||
f2({ x: 1, y: 1 });
|
||||
|
||||
// (arg: { x?: number, y?: number }) => void
|
||||
function f3({ x = 0, y = 0 }) { }
|
||||
f3({});
|
||||
f3({ x: 1 });
|
||||
f3({ y: 1 });
|
||||
f3({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x: number, y: number }) => void
|
||||
function f4({ x, y } = { x: 0, y: 0 }) { }
|
||||
f4();
|
||||
f4({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x: number, y?: number }) => void
|
||||
function f5({ x, y = 0 } = { x: 0 }) { }
|
||||
f5();
|
||||
f5({ x: 1 });
|
||||
f5({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x?: number, y?: number }) => void
|
||||
function f6({ x = 0, y = 0 } = {}) { }
|
||||
f6();
|
||||
f6({});
|
||||
f6({ x: 1 });
|
||||
f6({ y: 1 });
|
||||
f6({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
f7();
|
||||
f7({ a: {} });
|
||||
f7({ a: { x: 1 } });
|
||||
f7({ a: { y: 1 } });
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
|
||||
// (arg: [any, any]) => void
|
||||
function g1([x, y]) { }
|
||||
g1([1, 1]);
|
||||
|
||||
// (arg: [number, number]) => void
|
||||
function g2([x = 0, y = 0]) { }
|
||||
g2([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g3([x, y] = [0, 0]) { }
|
||||
g3();
|
||||
g3([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g4([x, y = 0] = [0]) { }
|
||||
g4();
|
||||
g4([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g5([x = 0, y = 0] = []) { }
|
||||
g5();
|
||||
g5([1, 1]);
|
||||
|
||||
|
||||
//// [destructuringWithLiteralInitializers.js]
|
||||
// (arg: { x: any, y: any }) => void
|
||||
function f1(_a) {
|
||||
var x = _a.x, y = _a.y;
|
||||
}
|
||||
f1({ x: 1, y: 1 });
|
||||
// (arg: { x: any, y?: number }) => void
|
||||
function f2(_a) {
|
||||
var x = _a.x, _b = _a.y, y = _b === void 0 ? 0 : _b;
|
||||
}
|
||||
f2({ x: 1 });
|
||||
f2({ x: 1, y: 1 });
|
||||
// (arg: { x?: number, y?: number }) => void
|
||||
function f3(_a) {
|
||||
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c;
|
||||
}
|
||||
f3({});
|
||||
f3({ x: 1 });
|
||||
f3({ y: 1 });
|
||||
f3({ x: 1, y: 1 });
|
||||
// (arg?: { x: number, y: number }) => void
|
||||
function f4(_a) {
|
||||
var _b = _a === void 0 ? { x: 0, y: 0 } : _a, x = _b.x, y = _b.y;
|
||||
}
|
||||
f4();
|
||||
f4({ x: 1, y: 1 });
|
||||
// (arg?: { x: number, y?: number }) => void
|
||||
function f5(_a) {
|
||||
var _b = _a === void 0 ? { x: 0 } : _a, x = _b.x, _c = _b.y, y = _c === void 0 ? 0 : _c;
|
||||
}
|
||||
f5();
|
||||
f5({ x: 1 });
|
||||
f5({ x: 1, y: 1 });
|
||||
// (arg?: { x?: number, y?: number }) => void
|
||||
function f6(_a) {
|
||||
var _b = _a === void 0 ? {} : _a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d;
|
||||
}
|
||||
f6();
|
||||
f6({});
|
||||
f6({ x: 1 });
|
||||
f6({ y: 1 });
|
||||
f6({ x: 1, y: 1 });
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7(_a) {
|
||||
var _b = (_a === void 0 ? { a: {} } : _a).a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d;
|
||||
}
|
||||
f7();
|
||||
f7({ a: {} });
|
||||
f7({ a: { x: 1 } });
|
||||
f7({ a: { y: 1 } });
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
// (arg: [any, any]) => void
|
||||
function g1(_a) {
|
||||
var x = _a[0], y = _a[1];
|
||||
}
|
||||
g1([1, 1]);
|
||||
// (arg: [number, number]) => void
|
||||
function g2(_a) {
|
||||
var _b = _a[0], x = _b === void 0 ? 0 : _b, _c = _a[1], y = _c === void 0 ? 0 : _c;
|
||||
}
|
||||
g2([1, 1]);
|
||||
// (arg?: [number, number]) => void
|
||||
function g3(_a) {
|
||||
var _b = _a === void 0 ? [0, 0] : _a, x = _b[0], y = _b[1];
|
||||
}
|
||||
g3();
|
||||
g3([1, 1]);
|
||||
// (arg?: [number, number]) => void
|
||||
function g4(_a) {
|
||||
var _b = _a === void 0 ? [0] : _a, x = _b[0], _c = _b[1], y = _c === void 0 ? 0 : _c;
|
||||
}
|
||||
g4();
|
||||
g4([1, 1]);
|
||||
// (arg?: [number, number]) => void
|
||||
function g5(_a) {
|
||||
var _b = _a === void 0 ? [] : _a, _c = _b[0], x = _c === void 0 ? 0 : _c, _d = _b[1], y = _d === void 0 ? 0 : _d;
|
||||
}
|
||||
g5();
|
||||
g5([1, 1]);
|
||||
@ -0,0 +1,194 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts ===
|
||||
// (arg: { x: any, y: any }) => void
|
||||
function f1({ x, y }) { }
|
||||
>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 1, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 1, 16))
|
||||
|
||||
f1({ x: 1, y: 1 });
|
||||
>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10))
|
||||
|
||||
// (arg: { x: any, y?: number }) => void
|
||||
function f2({ x, y = 0 }) { }
|
||||
>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 5, 16))
|
||||
|
||||
f2({ x: 1 });
|
||||
>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4))
|
||||
|
||||
f2({ x: 1, y: 1 });
|
||||
>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 7, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 7, 10))
|
||||
|
||||
// (arg: { x?: number, y?: number }) => void
|
||||
function f3({ x = 0, y = 0 }) { }
|
||||
>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 10, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 10, 20))
|
||||
|
||||
f3({});
|
||||
>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19))
|
||||
|
||||
f3({ x: 1 });
|
||||
>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 12, 4))
|
||||
|
||||
f3({ y: 1 });
|
||||
>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 4))
|
||||
|
||||
f3({ x: 1, y: 1 });
|
||||
>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 14, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 14, 10))
|
||||
|
||||
// (arg?: { x: number, y: number }) => void
|
||||
function f4({ x, y } = { x: 0, y: 0 }) { }
|
||||
>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 16))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 24))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 30))
|
||||
|
||||
f4();
|
||||
>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19))
|
||||
|
||||
f4({ x: 1, y: 1 });
|
||||
>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 19, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 19, 10))
|
||||
|
||||
// (arg?: { x: number, y?: number }) => void
|
||||
function f5({ x, y = 0 } = { x: 0 }) { }
|
||||
>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 22, 16))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 28))
|
||||
|
||||
f5();
|
||||
>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19))
|
||||
|
||||
f5({ x: 1 });
|
||||
>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4))
|
||||
|
||||
f5({ x: 1, y: 1 });
|
||||
>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 25, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 25, 10))
|
||||
|
||||
// (arg?: { x?: number, y?: number }) => void
|
||||
function f6({ x = 0, y = 0 } = {}) { }
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 28, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 28, 20))
|
||||
|
||||
f6();
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
|
||||
f6({});
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
|
||||
f6({ x: 1 });
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 31, 4))
|
||||
|
||||
f6({ y: 1 });
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 4))
|
||||
|
||||
f6({ x: 1, y: 1 });
|
||||
>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10))
|
||||
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 18))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 25))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39))
|
||||
|
||||
f7();
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
|
||||
f7({ a: {} });
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 38, 4))
|
||||
|
||||
f7({ a: { x: 1 } });
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 39, 4))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 9))
|
||||
|
||||
f7({ a: { y: 1 } });
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 40, 4))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 9))
|
||||
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19))
|
||||
>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 41, 4))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 41, 9))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 41, 15))
|
||||
|
||||
// (arg: [any, any]) => void
|
||||
function g1([x, y]) { }
|
||||
>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15))
|
||||
|
||||
g1([1, 1]);
|
||||
>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26))
|
||||
|
||||
// (arg: [number, number]) => void
|
||||
function g2([x = 0, y = 0]) { }
|
||||
>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 19))
|
||||
|
||||
g2([1, 1]);
|
||||
>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11))
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g3([x, y] = [0, 0]) { }
|
||||
>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15))
|
||||
|
||||
g3();
|
||||
>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11))
|
||||
|
||||
g3([1, 1]);
|
||||
>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11))
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g4([x, y = 0] = [0]) { }
|
||||
>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15))
|
||||
|
||||
g4();
|
||||
>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11))
|
||||
|
||||
g4([1, 1]);
|
||||
>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11))
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g5([x = 0, y = 0] = []) { }
|
||||
>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11))
|
||||
>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 62, 13))
|
||||
>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 62, 19))
|
||||
|
||||
g5();
|
||||
>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11))
|
||||
|
||||
g5([1, 1]);
|
||||
>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11))
|
||||
|
||||
@ -0,0 +1,310 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts ===
|
||||
// (arg: { x: any, y: any }) => void
|
||||
function f1({ x, y }) { }
|
||||
>f1 : ({ x, y }: { x: any; y: any; }) => void
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
f1({ x: 1, y: 1 });
|
||||
>f1({ x: 1, y: 1 }) : void
|
||||
>f1 : ({ x, y }: { x: any; y: any; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg: { x: any, y?: number }) => void
|
||||
function f2({ x, y = 0 }) { }
|
||||
>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void
|
||||
>x : any
|
||||
>y : number
|
||||
>0 : number
|
||||
|
||||
f2({ x: 1 });
|
||||
>f2({ x: 1 }) : void
|
||||
>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
f2({ x: 1, y: 1 });
|
||||
>f2({ x: 1, y: 1 }) : void
|
||||
>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg: { x?: number, y?: number }) => void
|
||||
function f3({ x = 0, y = 0 }) { }
|
||||
>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
|
||||
f3({});
|
||||
>f3({}) : void
|
||||
>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void
|
||||
>{} : {}
|
||||
|
||||
f3({ x: 1 });
|
||||
>f3({ x: 1 }) : void
|
||||
>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
f3({ y: 1 });
|
||||
>f3({ y: 1 }) : void
|
||||
>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void
|
||||
>{ y: 1 } : { y: number; }
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
f3({ x: 1, y: 1 });
|
||||
>f3({ x: 1, y: 1 }) : void
|
||||
>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: { x: number, y: number }) => void
|
||||
function f4({ x, y } = { x: 0, y: 0 }) { }
|
||||
>f4 : ({ x, y }?: { x: number; y: number; }) => void
|
||||
>x : number
|
||||
>y : number
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
|
||||
f4();
|
||||
>f4() : void
|
||||
>f4 : ({ x, y }?: { x: number; y: number; }) => void
|
||||
|
||||
f4({ x: 1, y: 1 });
|
||||
>f4({ x: 1, y: 1 }) : void
|
||||
>f4 : ({ x, y }?: { x: number; y: number; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: { x: number, y?: number }) => void
|
||||
function f5({ x, y = 0 } = { x: 0 }) { }
|
||||
>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void
|
||||
>x : number
|
||||
>y : number
|
||||
>0 : number
|
||||
>{ x: 0 } : { x: number; y?: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
|
||||
f5();
|
||||
>f5() : void
|
||||
>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void
|
||||
|
||||
f5({ x: 1 });
|
||||
>f5({ x: 1 }) : void
|
||||
>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
f5({ x: 1, y: 1 });
|
||||
>f5({ x: 1, y: 1 }) : void
|
||||
>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: { x?: number, y?: number }) => void
|
||||
function f6({ x = 0, y = 0 } = {}) { }
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
>{} : { x?: number; y?: number; }
|
||||
|
||||
f6();
|
||||
>f6() : void
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
|
||||
f6({});
|
||||
>f6({}) : void
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
>{} : {}
|
||||
|
||||
f6({ x: 1 });
|
||||
>f6({ x: 1 }) : void
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
f6({ y: 1 });
|
||||
>f6({ y: 1 }) : void
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
>{ y: 1 } : { y: number; }
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
f6({ x: 1, y: 1 });
|
||||
>f6({ x: 1, y: 1 }) : void
|
||||
>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
>a : any
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
>{ a: {} } : { a: { x?: number; y?: number; }; }
|
||||
>a : { x?: number; y?: number; }
|
||||
>{} : { x?: number; y?: number; }
|
||||
|
||||
f7();
|
||||
>f7() : void
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
|
||||
f7({ a: {} });
|
||||
>f7({ a: {} }) : void
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
>{ a: {} } : { a: {}; }
|
||||
>a : {}
|
||||
>{} : {}
|
||||
|
||||
f7({ a: { x: 1 } });
|
||||
>f7({ a: { x: 1 } }) : void
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
>{ a: { x: 1 } } : { a: { x: number; }; }
|
||||
>a : { x: number; }
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
f7({ a: { y: 1 } });
|
||||
>f7({ a: { y: 1 } }) : void
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
>{ a: { y: 1 } } : { a: { y: number; }; }
|
||||
>a : { y: number; }
|
||||
>{ y: 1 } : { y: number; }
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
>f7({ a: { x: 1, y: 1 } }) : void
|
||||
>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; }
|
||||
>a : { x: number; y: number; }
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
// (arg: [any, any]) => void
|
||||
function g1([x, y]) { }
|
||||
>g1 : ([x, y]: [any, any]) => void
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
g1([1, 1]);
|
||||
>g1([1, 1]) : void
|
||||
>g1 : ([x, y]: [any, any]) => void
|
||||
>[1, 1] : [number, number]
|
||||
>1 : number
|
||||
>1 : number
|
||||
|
||||
// (arg: [number, number]) => void
|
||||
function g2([x = 0, y = 0]) { }
|
||||
>g2 : ([x = 0, y = 0]: [number, number]) => void
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
|
||||
g2([1, 1]);
|
||||
>g2([1, 1]) : void
|
||||
>g2 : ([x = 0, y = 0]: [number, number]) => void
|
||||
>[1, 1] : [number, number]
|
||||
>1 : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g3([x, y] = [0, 0]) { }
|
||||
>g3 : ([x, y]?: [number, number]) => void
|
||||
>x : number
|
||||
>y : number
|
||||
>[0, 0] : [number, number]
|
||||
>0 : number
|
||||
>0 : number
|
||||
|
||||
g3();
|
||||
>g3() : void
|
||||
>g3 : ([x, y]?: [number, number]) => void
|
||||
|
||||
g3([1, 1]);
|
||||
>g3([1, 1]) : void
|
||||
>g3 : ([x, y]?: [number, number]) => void
|
||||
>[1, 1] : [number, number]
|
||||
>1 : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g4([x, y = 0] = [0]) { }
|
||||
>g4 : ([x, y = 0]?: [number, number]) => void
|
||||
>x : number
|
||||
>y : number
|
||||
>0 : number
|
||||
>[0] : [number, number]
|
||||
>0 : number
|
||||
|
||||
g4();
|
||||
>g4() : void
|
||||
>g4 : ([x, y = 0]?: [number, number]) => void
|
||||
|
||||
g4([1, 1]);
|
||||
>g4([1, 1]) : void
|
||||
>g4 : ([x, y = 0]?: [number, number]) => void
|
||||
>[1, 1] : [number, number]
|
||||
>1 : number
|
||||
>1 : number
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g5([x = 0, y = 0] = []) { }
|
||||
>g5 : ([x = 0, y = 0]?: [number, number]) => void
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number
|
||||
>0 : number
|
||||
>[] : [number, number]
|
||||
|
||||
g5();
|
||||
>g5() : void
|
||||
>g5 : ([x = 0, y = 0]?: [number, number]) => void
|
||||
|
||||
g5([1, 1]);
|
||||
>g5([1, 1]) : void
|
||||
>g5 : ([x = 0, y = 0]?: [number, number]) => void
|
||||
>[1, 1] : [number, number]
|
||||
>1 : number
|
||||
>1 : number
|
||||
|
||||
20
tests/baselines/reference/downlevelLetConst12.errors.txt
Normal file
20
tests/baselines/reference/downlevelLetConst12.errors.txt
Normal file
@ -0,0 +1,20 @@
|
||||
tests/cases/compiler/downlevelLetConst12.ts(7,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
|
||||
|
||||
==== tests/cases/compiler/downlevelLetConst12.ts (2 errors) ====
|
||||
|
||||
'use strict'
|
||||
// top level let\const should not be renamed
|
||||
let foo;
|
||||
const bar = 1;
|
||||
|
||||
let [baz] = [];
|
||||
~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
let {a: baz2} = { a: 1 };
|
||||
|
||||
const [baz3] = []
|
||||
~~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
const {a: baz4} = { a: 1 };
|
||||
@ -1,26 +0,0 @@
|
||||
=== tests/cases/compiler/downlevelLetConst12.ts ===
|
||||
|
||||
'use strict'
|
||||
// top level let\const should not be renamed
|
||||
let foo;
|
||||
>foo : Symbol(foo, Decl(downlevelLetConst12.ts, 3, 3))
|
||||
|
||||
const bar = 1;
|
||||
>bar : Symbol(bar, Decl(downlevelLetConst12.ts, 4, 5))
|
||||
|
||||
let [baz] = [];
|
||||
>baz : Symbol(baz, Decl(downlevelLetConst12.ts, 6, 5))
|
||||
|
||||
let {a: baz2} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17))
|
||||
>baz2 : Symbol(baz2, Decl(downlevelLetConst12.ts, 7, 5))
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17))
|
||||
|
||||
const [baz3] = []
|
||||
>baz3 : Symbol(baz3, Decl(downlevelLetConst12.ts, 9, 7))
|
||||
|
||||
const {a: baz4} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19))
|
||||
>baz4 : Symbol(baz4, Decl(downlevelLetConst12.ts, 10, 7))
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19))
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
=== tests/cases/compiler/downlevelLetConst12.ts ===
|
||||
|
||||
'use strict'
|
||||
>'use strict' : string
|
||||
|
||||
// top level let\const should not be renamed
|
||||
let foo;
|
||||
>foo : any
|
||||
|
||||
const bar = 1;
|
||||
>bar : number
|
||||
>1 : number
|
||||
|
||||
let [baz] = [];
|
||||
>baz : any
|
||||
>[] : undefined[]
|
||||
|
||||
let {a: baz2} = { a: 1 };
|
||||
>a : any
|
||||
>baz2 : number
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
const [baz3] = []
|
||||
>baz3 : any
|
||||
>[] : undefined[]
|
||||
|
||||
const {a: baz4} = { a: 1 };
|
||||
>a : any
|
||||
>baz4 : number
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type.
|
||||
tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature.
|
||||
tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type.
|
||||
tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature.
|
||||
|
||||
|
||||
==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ====
|
||||
==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ====
|
||||
'use strict'
|
||||
|
||||
declare function use(a: any);
|
||||
@ -156,6 +158,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin
|
||||
use(x);
|
||||
}
|
||||
for (let [y] = []; ;) {
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
use(y);
|
||||
}
|
||||
for (let {a: z} = {a: 1}; ;) {
|
||||
@ -169,6 +173,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin
|
||||
use(x);
|
||||
}
|
||||
for (const [y] = []; ;) {
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
use(y);
|
||||
}
|
||||
for (const {a: z} = { a: 1 }; ;) {
|
||||
|
||||
@ -87,12 +87,12 @@ var p8 = ({ a = 1 }) => { };
|
||||
>1 : number
|
||||
|
||||
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
|
||||
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>a : any
|
||||
>b : number
|
||||
>1 : number
|
||||
>{ b: 1 } : { b: number; }
|
||||
>{ b: 1 } : { b?: number; }
|
||||
>b : number
|
||||
>1 : number
|
||||
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(3,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts (3 errors) ====
|
||||
|
||||
|
||||
function f({} = {a: 1, b: "2", c: true}) {
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
|
||||
var x, y, z;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts ===
|
||||
|
||||
|
||||
function f({} = {a: 1, b: "2", c: true}) {
|
||||
>f : Symbol(f, Decl(emptyObjectBindingPatternParameter04.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(emptyObjectBindingPatternParameter04.ts, 2, 17))
|
||||
>b : Symbol(b, Decl(emptyObjectBindingPatternParameter04.ts, 2, 22))
|
||||
>c : Symbol(c, Decl(emptyObjectBindingPatternParameter04.ts, 2, 30))
|
||||
|
||||
var x, y, z;
|
||||
>x : Symbol(x, Decl(emptyObjectBindingPatternParameter04.ts, 3, 7))
|
||||
>y : Symbol(y, Decl(emptyObjectBindingPatternParameter04.ts, 3, 10))
|
||||
>z : Symbol(z, Decl(emptyObjectBindingPatternParameter04.ts, 3, 13))
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts ===
|
||||
|
||||
|
||||
function f({} = {a: 1, b: "2", c: true}) {
|
||||
>f : ({}?: { a: number; b: string; c: boolean; }) => void
|
||||
>{a: 1, b: "2", c: true} : { a: number; b: string; c: boolean; }
|
||||
>a : number
|
||||
>1 : number
|
||||
>b : string
|
||||
>"2" : string
|
||||
>c : boolean
|
||||
>true : boolean
|
||||
|
||||
var x, y, z;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,20): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (20 errors) ====
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var { x = 1, y } = {};
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
var { x, y = 1 } = {};
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
var { x = 1, y = 1 } = {};
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
({ x: x = 1, y } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
({ x, y: y = 1 } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
var { y } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
({ x } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
|
||||
({ y } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'.
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
|
||||
69
tests/baselines/reference/missingAndExcessProperties.js
Normal file
69
tests/baselines/reference/missingAndExcessProperties.js
Normal file
@ -0,0 +1,69 @@
|
||||
//// [missingAndExcessProperties.ts]
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
var { x = 1, y } = {};
|
||||
var { x, y = 1 } = {};
|
||||
var { x = 1, y = 1 } = {};
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
({ x: x = 1, y } = {});
|
||||
({ x, y: y = 1 } = {});
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
var { x } = { x: 0, y: 0 };
|
||||
var { y } = { x: 0, y: 0 };
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
({ x } = { x: 0, y: 0 });
|
||||
({ y } = { x: 0, y: 0 });
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
|
||||
|
||||
//// [missingAndExcessProperties.js]
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var _a = {}, x = _a.x, y = _a.y;
|
||||
var _b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y;
|
||||
var _d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e;
|
||||
var _f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h;
|
||||
}
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x, y;
|
||||
(_a = {}, x = _a.x, y = _a.y, _a);
|
||||
(_b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y, _b);
|
||||
(_d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e, _d);
|
||||
(_f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h, _f);
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
}
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var _a = { x: 0, y: 0 };
|
||||
var x = { x: 0, y: 0 }.x;
|
||||
var y = { x: 0, y: 0 }.y;
|
||||
var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y;
|
||||
}
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x, y;
|
||||
({ x: 0, y: 0 });
|
||||
(_a = { x: 0, y: 0 }, x = _a.x, _a);
|
||||
(_b = { x: 0, y: 0 }, y = _b.y, _b);
|
||||
(_c = { x: 0, y: 0 }, x = _c.x, y = _c.y, _c);
|
||||
var _a, _b, _c;
|
||||
}
|
||||
@ -5,7 +5,7 @@ var c = {};
|
||||
|
||||
[...c] = ["", 0];
|
||||
>[...c] = ["", 0] : (string | number)[]
|
||||
>[...c] : {}[]
|
||||
>[...c] : undefined[]
|
||||
>...c : any
|
||||
>c : {}
|
||||
>["", 0] : (string | number)[]
|
||||
|
||||
@ -5,7 +5,7 @@ var c = {};
|
||||
|
||||
[...c] = ["", 0];
|
||||
>[...c] = ["", 0] : (string | number)[]
|
||||
>[...c] : {}[]
|
||||
>[...c] : undefined[]
|
||||
>...c : any
|
||||
>c : {}
|
||||
>["", 0] : (string | number)[]
|
||||
|
||||
@ -2,8 +2,8 @@ function f0() {
|
||||
var [] = [1, "hello"];
|
||||
var [x] = [1, "hello"];
|
||||
var [x, y] = [1, "hello"];
|
||||
var [x, y, z] = [1, "hello"]; // Error
|
||||
var [,, z] = [0, 1, 2];
|
||||
var [x, y, z] = [1, "hello"];
|
||||
var [,, x] = [0, 1, 2];
|
||||
var x: number;
|
||||
var y: string;
|
||||
}
|
||||
@ -19,14 +19,14 @@ function f1() {
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" };
|
||||
var { x } = { x: 5, y: "hello" };
|
||||
var { y } = { x: 5, y: "hello" };
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x, y } = { x: 5, y: "hello" };
|
||||
var x: number;
|
||||
var y: string;
|
||||
var { x: a } = { x: 5, y: "hello" };
|
||||
var { y: b } = { x: 5, y: "hello" };
|
||||
var { x: a } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y: b } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x: a, y: b } = { x: 5, y: "hello" };
|
||||
var a: number;
|
||||
var b: string;
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
// (arg: { x: any, y: any }) => void
|
||||
function f1({ x, y }) { }
|
||||
f1({ x: 1, y: 1 });
|
||||
|
||||
// (arg: { x: any, y?: number }) => void
|
||||
function f2({ x, y = 0 }) { }
|
||||
f2({ x: 1 });
|
||||
f2({ x: 1, y: 1 });
|
||||
|
||||
// (arg: { x?: number, y?: number }) => void
|
||||
function f3({ x = 0, y = 0 }) { }
|
||||
f3({});
|
||||
f3({ x: 1 });
|
||||
f3({ y: 1 });
|
||||
f3({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x: number, y: number }) => void
|
||||
function f4({ x, y } = { x: 0, y: 0 }) { }
|
||||
f4();
|
||||
f4({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x: number, y?: number }) => void
|
||||
function f5({ x, y = 0 } = { x: 0 }) { }
|
||||
f5();
|
||||
f5({ x: 1 });
|
||||
f5({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { x?: number, y?: number }) => void
|
||||
function f6({ x = 0, y = 0 } = {}) { }
|
||||
f6();
|
||||
f6({});
|
||||
f6({ x: 1 });
|
||||
f6({ y: 1 });
|
||||
f6({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
f7();
|
||||
f7({ a: {} });
|
||||
f7({ a: { x: 1 } });
|
||||
f7({ a: { y: 1 } });
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
|
||||
// (arg: [any, any]) => void
|
||||
function g1([x, y]) { }
|
||||
g1([1, 1]);
|
||||
|
||||
// (arg: [number, number]) => void
|
||||
function g2([x = 0, y = 0]) { }
|
||||
g2([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g3([x, y] = [0, 0]) { }
|
||||
g3();
|
||||
g3([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g4([x, y = 0] = [0]) { }
|
||||
g4();
|
||||
g4([1, 1]);
|
||||
|
||||
// (arg?: [number, number]) => void
|
||||
function g5([x = 0, y = 0] = []) { }
|
||||
g5();
|
||||
g5([1, 1]);
|
||||
@ -0,0 +1,33 @@
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
var { x = 1, y } = {};
|
||||
var { x, y = 1 } = {};
|
||||
var { x = 1, y = 1 } = {};
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
({ x: x = 1, y } = {});
|
||||
({ x, y: y = 1 } = {});
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
var { x } = { x: 0, y: 0 };
|
||||
var { y } = { x: 0, y: 0 };
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
({ x } = { x: 0, y: 0 });
|
||||
({ y } = { x: 0, y: 0 });
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user