diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt deleted file mode 100644 index 447ccec5ddf..00000000000 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt +++ /dev/null @@ -1,67 +0,0 @@ -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. - Types of property 'show' are incompatible. - Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. - - -==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ==== - interface Show { - show: (x: number) => string; - } - function f({ show: showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - function f2({ "show": showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - function f3({ ["show"]: showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface Nested { - nested: Show - } - function ff({ nested: nestedRename = { show: v => v } }: Nested) {} - ~~~~~~~~~~~~ -!!! error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. -!!! error TS2322: Types of property 'show' are incompatible. -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface StringIdentity { - stringIdentity(s: string): string; - } - let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; - ~~ -!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface Tuples { - prop: [string, number]; - } - function g({ prop = [101, 1234] }: Tuples) {} - ~~~~ -!!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface StringUnion { - prop: "foo" | "bar"; - } - function h({ prop = "baz" }: StringUnion) {} - ~~~~ -!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. - \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols new file mode 100644 index 00000000000..a9013e7f98e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols @@ -0,0 +1,88 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts === +interface Show { +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + + show: (x: number) => string; +>show : Symbol(Show.show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 16)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 1, 11)) +} +function f({ show: showRename = v => v }: Show) {} +>f : Symbol(f, Decl(contextuallyTypedBindingInitializerNegative.ts, 2, 1)) +>show : Symbol(Show.show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 16)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 12)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 31)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 31)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +function f2({ "show": showRename = v => v }: Show) {} +>f2 : Symbol(f2, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 50)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 34)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 34)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +function f3({ ["show"]: showRename = v => v }: Show) {} +>f3 : Symbol(f3, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 53)) +>"show" : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 13)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 36)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 36)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +interface Nested { +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 55)) + + nested: Show +>nested : Symbol(Nested.nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 7, 18)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} +>ff : Symbol(ff, Decl(contextuallyTypedBindingInitializerNegative.ts, 9, 1)) +>nested : Symbol(Nested.nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 7, 18)) +>nestedRename : Symbol(nestedRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 13)) +>show : Symbol(show, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 38)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 44)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 44)) +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 55)) + +interface StringIdentity { +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 67)) + + stringIdentity(s: string): string; +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 12, 26)) +>s : Symbol(s, Decl(contextuallyTypedBindingInitializerNegative.ts, 13, 19)) +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 12, 26)) +>id : Symbol(id, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 5)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 26)) +>arg.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 26)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 67)) +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 66)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 82)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 82)) + +interface Tuples { +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 91)) + + prop: [string, number]; +>prop : Symbol(Tuples.prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 17, 18)) +} +function g({ prop = [101, 1234] }: Tuples) {} +>g : Symbol(g, Decl(contextuallyTypedBindingInitializerNegative.ts, 19, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 12)) +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 91)) + +interface StringUnion { +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 45)) + + prop: "foo" | "bar"; +>prop : Symbol(StringUnion.prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 22, 23)) +} +function h({ prop = "baz" }: StringUnion) {} +>h : Symbol(h, Decl(contextuallyTypedBindingInitializerNegative.ts, 24, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 25, 12)) +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 45)) + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types new file mode 100644 index 00000000000..7e922332055 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts === +interface Show { +>Show : Show + + show: (x: number) => string; +>show : (x: number) => string +>x : number +} +function f({ show: showRename = v => v }: Show) {} +>f : ({show: showRename}: Show) => void +>show : any +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +function f2({ "show": showRename = v => v }: Show) {} +>f2 : ({"show": showRename}: Show) => void +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +function f3({ ["show"]: showRename = v => v }: Show) {} +>f3 : ({["show"]: showRename}: Show) => void +>"show" : string +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +interface Nested { +>Nested : Nested + + nested: Show +>nested : Show +>Show : Show +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} +>ff : ({nested: nestedRename}: Nested) => void +>nested : any +>nestedRename : Show | { show: (v: number) => number; } +>{ show: v => v } : { show: (v: number) => number; } +>show : (v: number) => number +>v => v : (v: number) => number +>v : number +>v : number +>Nested : Nested + +interface StringIdentity { +>StringIdentity : StringIdentity + + stringIdentity(s: string): string; +>stringIdentity : (s: string) => string +>s : string +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : any +>id : ((s: string) => string) | ((arg: string) => number) +>arg => arg.length : (arg: string) => number +>arg : string +>arg.length : number +>arg : string +>length : number +>StringIdentity : StringIdentity +>{ stringIdentity: x => x} : { stringIdentity: (x: string) => string; } +>stringIdentity : (x: string) => string +>x => x : (x: string) => string +>x : string +>x : string + +interface Tuples { +>Tuples : Tuples + + prop: [string, number]; +>prop : [string, number] +} +function g({ prop = [101, 1234] }: Tuples) {} +>g : ({prop}: Tuples) => void +>prop : [string, number] | [number, number] +>[101, 1234] : [number, number] +>101 : number +>1234 : number +>Tuples : Tuples + +interface StringUnion { +>StringUnion : StringUnion + + prop: "foo" | "bar"; +>prop : "foo" | "bar" +} +function h({ prop = "baz" }: StringUnion) {} +>h : ({prop}: StringUnion) => void +>prop : "foo" | "bar" | "baz" +>"baz" : "baz" +>StringUnion : StringUnion + diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 3ed9e241c39..33c2db0a550 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): 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(58,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. 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. @@ -96,10 +96,10 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f7() { var [x = 0, y = 1] = [1, "hello"]; // Error, initializer for y must be string - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. var x: number; var y: string; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. } function f8() { diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index e22b23122d3..610167a1bc0 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -3,7 +3,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss 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]'. Type 'number' is not assignable to type 'boolean'. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. @@ -11,7 +10,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. -==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (7 errors) ==== // 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]]] = [] // Error @@ -38,8 +37,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss return <[number, number, number]>[1, 2, 3]; } var [b3 = "string", b4, b5] = bar(); // Error - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'Number'. // 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 not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index c4693fac23f..35eb23c9e6a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -62,11 +62,11 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >"hello" : string var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : any +>b5 : number >3 : number ->b6 : any +>b6 : boolean >true : boolean ->b7 : any +>b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] >undefined : undefined diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index 847831ccc84..f124e203e1f 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -62,11 +62,11 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >"hello" : string var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : any +>b5 : number >3 : number ->b6 : any +>b6 : boolean >true : boolean ->b7 : any +>b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] >undefined : undefined diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index bdbda6f9a96..7658de962d9 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -5,16 +5,11 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4 Type '[[boolean]]' is not assignable to type '[[string]]'. Type '[boolean]' is not assignable to type '[string]'. Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. - Types of property 't2' are incompatible. - Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,16): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,24): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(19,10): error TS2322: Type 'string[]' is not assignable to type 'number[]'. - Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (6 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (4 errors) ==== // The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error @@ -33,10 +28,6 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var temp = { t1: true, t2: "false" }; var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error - ~~ -!!! error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. -!!! error TS2322: Types of property 't2' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with @@ -50,7 +41,4 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. - var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error - ~~ -!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file + var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error \ No newline at end of file diff --git a/tests/baselines/reference/for-of43.errors.txt b/tests/baselines/reference/for-of43.errors.txt deleted file mode 100644 index c5790278e53..00000000000 --- a/tests/baselines/reference/for-of43.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/es6/for-ofStatements/for-of43.ts(2,25): error TS2322: Type 'boolean' is not assignable to type 'number'. - - -==== tests/cases/conformance/es6/for-ofStatements/for-of43.ts (1 errors) ==== - var array = [{ x: "", y: 0 }] - for (var {x: a = "", y: b = true} of array) { - ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. - a; - b; - } \ No newline at end of file diff --git a/tests/baselines/reference/for-of43.symbols b/tests/baselines/reference/for-of43.symbols new file mode 100644 index 00000000000..4add17ad547 --- /dev/null +++ b/tests/baselines/reference/for-of43.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of43.ts === +var array = [{ x: "", y: 0 }] +>array : Symbol(array, Decl(for-of43.ts, 0, 3)) +>x : Symbol(x, Decl(for-of43.ts, 0, 14)) +>y : Symbol(y, Decl(for-of43.ts, 0, 21)) + +for (var {x: a = "", y: b = true} of array) { +>x : Symbol(x, Decl(for-of43.ts, 0, 14)) +>a : Symbol(a, Decl(for-of43.ts, 1, 10)) +>y : Symbol(y, Decl(for-of43.ts, 0, 21)) +>b : Symbol(b, Decl(for-of43.ts, 1, 20)) +>array : Symbol(array, Decl(for-of43.ts, 0, 3)) + + a; +>a : Symbol(a, Decl(for-of43.ts, 1, 10)) + + b; +>b : Symbol(b, Decl(for-of43.ts, 1, 20)) +} diff --git a/tests/baselines/reference/for-of43.types b/tests/baselines/reference/for-of43.types new file mode 100644 index 00000000000..a11cd47182c --- /dev/null +++ b/tests/baselines/reference/for-of43.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of43.ts === +var array = [{ x: "", y: 0 }] +>array : { x: string; y: number; }[] +>[{ x: "", y: 0 }] : { x: string; y: number; }[] +>{ x: "", y: 0 } : { x: string; y: number; } +>x : string +>"" : string +>y : number +>0 : number + +for (var {x: a = "", y: b = true} of array) { +>x : any +>a : string +>"" : string +>y : any +>b : number | boolean +>true : boolean +>array : { x: string; y: number; }[] + + a; +>a : string + + b; +>b : number | boolean +} diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types index ef0a3f2c25b..9d07a26558d 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types @@ -33,13 +33,13 @@ let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error >3 : number let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error ->a3 : number +>a3 : any >undefined : any >undefined : undefined ->b3 : number +>b3 : any >null : any >null : null ->c3 : number +>c3 : any >undefined : any >undefined : undefined >[1, 2, 3] : [number, number, number] @@ -106,13 +106,13 @@ let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; >3 : number let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error ->x3 : number +>x3 : any >undefined : any >undefined : undefined ->y3 : number +>y3 : any >null : any >null : null ->z3 : number +>z3 : any >undefined : any >undefined : undefined >{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; }