From 2e56012ac393582fd50595ddf193dea0b78b0c5b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Dec 2015 16:57:22 -0800 Subject: [PATCH] Accepting new baselines --- ...functionConstraintSatisfaction2.errors.txt | 1 - ...thObjectTypeArgsAndConstraints4.errors.txt | 7 +- ...thObjectTypeArgsAndConstraints5.errors.txt | 12 ++- .../reference/maxConstraints.errors.txt | 4 +- ...essOnTypeParameterWithConstraints3.symbols | 3 + ...ccessOnTypeParameterWithConstraints3.types | 18 ++--- ...OnTypeParameterWithConstraints5.errors.txt | 5 +- ...meterAsTypeParameterConstraint2.errors.txt | 53 ++++++++++++ ...arameterAsTypeParameterConstraint2.symbols | 61 -------------- ...eParameterAsTypeParameterConstraint2.types | 81 ------------------- 10 files changed, 88 insertions(+), 157 deletions(-) create mode 100644 tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt delete mode 100644 tests/baselines/reference/typeParameterAsTypeParameterConstraint2.symbols delete mode 100644 tests/baselines/reference/typeParameterAsTypeParameterConstraint2.types diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index cdefdacb1d5..7b3aa92828d 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -18,7 +18,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain Type 'new (x: T) => T' provides no match for the signature '(x: string): string' tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(34,16): error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'. Type 'F2' provides no match for the signature '(x: string): string' -tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(36,38): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'. Type '() => void' is not assignable to type '(x: string) => string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt index cc4eb418596..c5c6cbe05c6 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints4.errors.txt @@ -1,7 +1,9 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(19,17): error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. + Property 'y' is missing in type 'C'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts(30,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints4.ts (2 errors) ==== // Generic call with constraints infering type parameter from object member properties class C { @@ -21,6 +23,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var d: D; var r = foo(c, d); var r2 = foo(d, c); // error because C does not extend D + ~ +!!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. +!!! error TS2345: Property 'y' is missing in type 'C'. var r3 = foo(c, { x: '', foo: c }); var r4 = foo(null, null); var r5 = foo({}, null); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt index b2e69ce7505..2632e867edf 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints5.errors.txt @@ -1,7 +1,11 @@ +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(18,17): error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. + Property 'y' is missing in type 'C'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(19,23): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'. + Type 'void' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts(22,24): error TS2345: Argument of type 'C' is not assignable to parameter of type 'T'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints5.ts (3 errors) ==== // Generic call with constraints infering type parameter from object member properties class C { @@ -20,7 +24,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj var c: C; var d: D; var r2 = foo(d, c); // the constraints are self-referencing, no downstream error + ~ +!!! error TS2345: Argument of type 'C' is not assignable to parameter of type 'D'. +!!! error TS2345: Property 'y' is missing in type 'C'. var r9 = foo(() => 1, () => { }); // the constraints are self-referencing, no downstream error + ~~~~~~~~~ +!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'. +!!! error TS2345: Type 'void' is not assignable to type 'number'. function other() { var r5 = foo(c, d); // error diff --git a/tests/baselines/reference/maxConstraints.errors.txt b/tests/baselines/reference/maxConstraints.errors.txt index 1f8af2ffacd..03e7158f725 100644 --- a/tests/baselines/reference/maxConstraints.errors.txt +++ b/tests/baselines/reference/maxConstraints.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. +tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. Property 'compareTo' is missing in type 'Number'. @@ -12,5 +12,5 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'nu var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; var maxResult = max2(1, 2); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. !!! error TS2345: Property 'compareTo' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.symbols b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.symbols index 0761c4612f1..6d1074b14f6 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.symbols +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.symbols @@ -135,11 +135,14 @@ var a: { } var r3 = a().foo(); // error, no inferences for U so it doesn't satisfy constraint >r3 : Symbol(r3, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 41, 3)) +>a().foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9)) >a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3)) +>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9)) var r3b = a()['foo'](); >r3b : Symbol(r3b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 42, 3)) >a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3)) +>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9)) // parameter supplied for type argument inference for U var r3c = a(new B()).foo(); // valid call to an invalid function, U is inferred as B, which has a foo diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types index ea325190da6..f2423f2bff8 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types @@ -154,18 +154,18 @@ var a: { >U : U } var r3 = a().foo(); // error, no inferences for U so it doesn't satisfy constraint ->r3 : any ->a().foo() : any ->a().foo : any ->a() : any +>r3 : string +>a().foo() : string +>a().foo : () => string +>a() : A >a : { (): T; (x: U): U; } ->foo : any +>foo : () => string var r3b = a()['foo'](); ->r3b : any ->a()['foo']() : any ->a()['foo'] : any ->a() : any +>r3b : string +>a()['foo']() : string +>a()['foo'] : () => string +>a() : A >a : { (): T; (x: U): U; } >'foo' : string diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt index d7aa10cc353..fd012d0e5a5 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt @@ -1,10 +1,11 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(15,32): error TS2339: Property 'notHere' does not exist on type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(25,16): error TS2339: Property 'notHere' does not exist on type 'B'. +tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(32,22): error TS2339: Property 'notHere' does not exist on type 'A'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,16): error TS2322: Type 'string' is not assignable to type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,22): error TS2339: Property 'notHere' does not exist on type 'U'. -==== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts (4 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts (5 errors) ==== class A { foo(): string { return ''; } } @@ -41,6 +42,8 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOn } // BUG 794164 var r3: string = a().notHere(); + ~~~~~~~ +!!! error TS2339: Property 'notHere' does not exist on type 'A'. var r3b: string = a()['foo'](); var b = { diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt new file mode 100644 index 00000000000..282e942e0f7 --- /dev/null +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. + Types of property 'length' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,9): error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. + Types of property 'length' are incompatible. + Type '{}' is not assignable to type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(18,10): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. + Types of property 'length' are incompatible. + Type 'number' is not assignable to type 'any[]'. + Property 'length' is missing in type 'Number'. + + +==== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts (6 errors) ==== + // using a type parameter as a constraint for a type parameter is invalid + // these should be errors unless otherwise noted + + function foo(x: T, y: U): U { return y; } // this is now an error + + foo(1, ''); + ~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + foo(1, {}); + ~~ +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. + + interface NumberVariant extends Number { + x: number; + } + var n: NumberVariant; + var r3 = foo(1, n); + ~ +!!! error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'. + + function foo2(x: T, y: U) { return y; } // this is now an error + foo2(1, { length: '' }); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. +!!! error TS2345: Types of property 'length' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + foo2(1, { length: {} }); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'. +!!! error TS2345: Types of property 'length' are incompatible. +!!! error TS2345: Type '{}' is not assignable to type 'number'. + foo2([], ['']); + ~~~~ +!!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'. +!!! error TS2345: Types of property 'length' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'any[]'. +!!! error TS2345: Property 'length' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.symbols b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.symbols deleted file mode 100644 index b6fde452280..00000000000 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.symbols +++ /dev/null @@ -1,61 +0,0 @@ -=== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts === -// using a type parameter as a constraint for a type parameter is invalid -// these should be errors unless otherwise noted - -function foo(x: T, y: U): U { return y; } // this is now an error ->foo : Symbol(foo, Decl(typeParameterAsTypeParameterConstraint2.ts, 0, 0)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 13)) ->U : Symbol(U, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 15)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 13)) ->x : Symbol(x, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 29)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 13)) ->y : Symbol(y, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 34)) ->U : Symbol(U, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 15)) ->U : Symbol(U, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 15)) ->y : Symbol(y, Decl(typeParameterAsTypeParameterConstraint2.ts, 3, 34)) - -foo(1, ''); ->foo : Symbol(foo, Decl(typeParameterAsTypeParameterConstraint2.ts, 0, 0)) - -foo(1, {}); ->foo : Symbol(foo, Decl(typeParameterAsTypeParameterConstraint2.ts, 0, 0)) - -interface NumberVariant extends Number { ->NumberVariant : Symbol(NumberVariant, Decl(typeParameterAsTypeParameterConstraint2.ts, 6, 11)) ->Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) - - x: number; ->x : Symbol(x, Decl(typeParameterAsTypeParameterConstraint2.ts, 8, 40)) -} -var n: NumberVariant; ->n : Symbol(n, Decl(typeParameterAsTypeParameterConstraint2.ts, 11, 3)) ->NumberVariant : Symbol(NumberVariant, Decl(typeParameterAsTypeParameterConstraint2.ts, 6, 11)) - -var r3 = foo(1, n); ->r3 : Symbol(r3, Decl(typeParameterAsTypeParameterConstraint2.ts, 12, 3)) ->foo : Symbol(foo, Decl(typeParameterAsTypeParameterConstraint2.ts, 0, 0)) ->n : Symbol(n, Decl(typeParameterAsTypeParameterConstraint2.ts, 11, 3)) - -function foo2(x: T, y: U) { return y; } // this is now an error ->foo2 : Symbol(foo2, Decl(typeParameterAsTypeParameterConstraint2.ts, 12, 19)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 14)) ->U : Symbol(U, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 16)) ->length : Symbol(length, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 28)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 14)) ->x : Symbol(x, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 42)) ->T : Symbol(T, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 14)) ->y : Symbol(y, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 47)) ->U : Symbol(U, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 16)) ->y : Symbol(y, Decl(typeParameterAsTypeParameterConstraint2.ts, 14, 47)) - -foo2(1, { length: '' }); ->foo2 : Symbol(foo2, Decl(typeParameterAsTypeParameterConstraint2.ts, 12, 19)) ->length : Symbol(length, Decl(typeParameterAsTypeParameterConstraint2.ts, 15, 9)) - -foo2(1, { length: {} }); ->foo2 : Symbol(foo2, Decl(typeParameterAsTypeParameterConstraint2.ts, 12, 19)) ->length : Symbol(length, Decl(typeParameterAsTypeParameterConstraint2.ts, 16, 9)) - -foo2([], ['']); ->foo2 : Symbol(foo2, Decl(typeParameterAsTypeParameterConstraint2.ts, 12, 19)) - diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.types deleted file mode 100644 index e73cdaeda53..00000000000 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.types +++ /dev/null @@ -1,81 +0,0 @@ -=== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts === -// using a type parameter as a constraint for a type parameter is invalid -// these should be errors unless otherwise noted - -function foo(x: T, y: U): U { return y; } // this is now an error ->foo : (x: T, y: U) => U ->T : T ->U : U ->T : T ->x : T ->T : T ->y : U ->U : U ->U : U ->y : U - -foo(1, ''); ->foo(1, '') : any ->foo : (x: T, y: U) => U ->1 : number ->'' : string - -foo(1, {}); ->foo(1, {}) : any ->foo : (x: T, y: U) => U ->1 : number ->{} : {} - -interface NumberVariant extends Number { ->NumberVariant : NumberVariant ->Number : Number - - x: number; ->x : number -} -var n: NumberVariant; ->n : NumberVariant ->NumberVariant : NumberVariant - -var r3 = foo(1, n); ->r3 : any ->foo(1, n) : any ->foo : (x: T, y: U) => U ->1 : number ->n : NumberVariant - -function foo2(x: T, y: U) { return y; } // this is now an error ->foo2 : (x: T, y: U) => U ->T : T ->U : U ->length : T ->T : T ->x : T ->T : T ->y : U ->U : U ->y : U - -foo2(1, { length: '' }); ->foo2(1, { length: '' }) : { length: any; } ->foo2 : (x: T, y: U) => U ->1 : number ->{ length: '' } : { length: string; } ->length : string ->'' : string - -foo2(1, { length: {} }); ->foo2(1, { length: {} }) : { length: any; } ->foo2 : (x: T, y: U) => U ->1 : number ->{ length: {} } : { length: {}; } ->length : {} ->{} : {} - -foo2([], ['']); ->foo2([], ['']) : { length: any; } ->foo2 : (x: T, y: U) => U ->[] : undefined[] ->[''] : string[] ->'' : string -