Skip to content

Commit e95097c

Browse files
committed
Update baselines
1 parent 27843d3 commit e95097c

16 files changed

+300
-86
lines changed

tests/baselines/reference/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.errors.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcre
99
Type 'unknown' is not assignable to type 'A'.
1010
Type 'ReturnType<FunctionsObj<T>[string]>' is not assignable to type 'A'.
1111
Type 'unknown' is not assignable to type 'A'.
12-
Property 'x' is missing in type '{}' but required in type 'A'.
12+
Type 'unknown' is not assignable to type 'A'.
1313

1414

1515
==== tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.ts (1 errors) ====
@@ -38,8 +38,7 @@ tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcre
3838
!!! error TS2322: Type 'unknown' is not assignable to type 'A'.
3939
!!! error TS2322: Type 'ReturnType<FunctionsObj<T>[string]>' is not assignable to type 'A'.
4040
!!! error TS2322: Type 'unknown' is not assignable to type 'A'.
41-
!!! error TS2322: Property 'x' is missing in type '{}' but required in type 'A'.
42-
!!! related TS2728 tests/cases/compiler/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.ts:1:15: 'x' is declared here.
41+
!!! error TS2322: Type 'unknown' is not assignable to type 'A'.
4342
}
4443

4544
// Original CFA report of the above issue

tests/baselines/reference/privateFieldAssignabilityFromUnknown.errors.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts(2,3): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
2-
tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts(5,7): error TS2741: Property '#field' is missing in type '{}' but required in type 'Class'.
2+
tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts(5,7): error TS2322: Type 'unknown' is not assignable to type 'Class'.
33

44

55
==== tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts (2 errors) ====
@@ -11,6 +11,5 @@ tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts(5,7): error TS2741:
1111

1212
const task: Class = {} as unknown;
1313
~~~~
14-
!!! error TS2741: Property '#field' is missing in type '{}' but required in type 'Class'.
15-
!!! related TS2728 tests/cases/compiler/privateFieldAssignabilityFromUnknown.ts:2:3: '#field' is declared here.
14+
!!! error TS2322: Type 'unknown' is not assignable to type 'Class'.
1615

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts(5,22): error TS2339: Property 'toString' does not exist on type 'T'.
2+
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts(21,22): error TS2339: Property 'toString' does not exist on type 'unknown'.
3+
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts(27,22): error TS2339: Property 'toString' does not exist on type 'T'.
4+
5+
6+
==== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithoutConstraints.ts (3 errors) ====
7+
class C<T> {
8+
f() {
9+
var x: T;
10+
var a = x['toString'](); // should be string
11+
return a + x.toString();
12+
~~~~~~~~
13+
!!! error TS2339: Property 'toString' does not exist on type 'T'.
14+
}
15+
}
16+
17+
var r = (new C<number>()).f();
18+
19+
interface I<T> {
20+
foo: T;
21+
}
22+
var i: I<number>;
23+
var r2 = i.foo.toString();
24+
var r2b = i.foo['toString']();
25+
26+
var a: {
27+
<T>(): T;
28+
}
29+
var r3: string = a().toString();
30+
~~~~~~~~
31+
!!! error TS2339: Property 'toString' does not exist on type 'unknown'.
32+
var r3b: string = a()['toString']();
33+
34+
var b = {
35+
foo: <T>(x: T) => {
36+
var a = x['toString'](); // should be string
37+
return a + x.toString();
38+
~~~~~~~~
39+
!!! error TS2339: Property 'toString' does not exist on type 'T'.
40+
}
41+
}
42+
43+
var r4 = b.foo(1);

tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.symbols

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ class C<T> {
1313
var a = x['toString'](); // should be string
1414
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 3, 11))
1515
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 2, 11))
16-
>'toString' : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
1716

1817
return a + x.toString();
1918
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 3, 11))
20-
>x.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
2119
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 2, 11))
22-
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
2320
}
2421
}
2522

@@ -65,14 +62,11 @@ var a: {
6562
}
6663
var r3: string = a().toString();
6764
>r3 : Symbol(r3, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 20, 3))
68-
>a().toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
6965
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 17, 3))
70-
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
7166

7267
var r3b: string = a()['toString']();
7368
>r3b : Symbol(r3b, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 21, 3))
7469
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 17, 3))
75-
>'toString' : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
7670

7771
var b = {
7872
>b : Symbol(b, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 23, 3))
@@ -86,13 +80,10 @@ var b = {
8680
var a = x['toString'](); // should be string
8781
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 25, 11))
8882
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 24, 13))
89-
>'toString' : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
9083

9184
return a + x.toString();
9285
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 25, 11))
93-
>x.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
9486
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithoutConstraints.ts, 24, 13))
95-
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
9687
}
9788
}
9889

tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.types

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ class C<T> {
33
>C : C<T>
44

55
f() {
6-
>f : () => string
6+
>f : () => any
77

88
var x: T;
99
>x : T
1010

1111
var a = x['toString'](); // should be string
12-
>a : string
13-
>x['toString']() : string
14-
>x['toString'] : () => string
12+
>a : any
13+
>x['toString']() : any
14+
>x['toString'] : any
1515
>x : T
1616
>'toString' : "toString"
1717

1818
return a + x.toString();
19-
>a + x.toString() : string
20-
>a : string
21-
>x.toString() : string
22-
>x.toString : () => string
19+
>a + x.toString() : any
20+
>a : any
21+
>x.toString() : any
22+
>x.toString : any
2323
>x : T
24-
>toString : () => string
24+
>toString : any
2525
}
2626
}
2727

2828
var r = (new C<number>()).f();
29-
>r : string
30-
>(new C<number>()).f() : string
31-
>(new C<number>()).f : () => string
29+
>r : any
30+
>(new C<number>()).f() : any
31+
>(new C<number>()).f : () => any
3232
>(new C<number>()) : C<number>
3333
>new C<number>() : C<number>
3434
>C : typeof C
35-
>f : () => string
35+
>f : () => any
3636

3737
interface I<T> {
3838
foo: T;
@@ -66,51 +66,51 @@ var a: {
6666
}
6767
var r3: string = a().toString();
6868
>r3 : string
69-
>a().toString() : string
70-
>a().toString : () => string
69+
>a().toString() : any
70+
>a().toString : any
7171
>a() : unknown
7272
>a : <T>() => T
73-
>toString : () => string
73+
>toString : any
7474

7575
var r3b: string = a()['toString']();
7676
>r3b : string
77-
>a()['toString']() : string
78-
>a()['toString'] : () => string
77+
>a()['toString']() : any
78+
>a()['toString'] : any
7979
>a() : unknown
8080
>a : <T>() => T
8181
>'toString' : "toString"
8282

8383
var b = {
84-
>b : { foo: <T>(x: T) => string; }
85-
>{ foo: <T>(x: T) => { var a = x['toString'](); // should be string return a + x.toString(); }} : { foo: <T>(x: T) => string; }
84+
>b : { foo: <T>(x: T) => any; }
85+
>{ foo: <T>(x: T) => { var a = x['toString'](); // should be string return a + x.toString(); }} : { foo: <T>(x: T) => any; }
8686

8787
foo: <T>(x: T) => {
88-
>foo : <T>(x: T) => string
89-
><T>(x: T) => { var a = x['toString'](); // should be string return a + x.toString(); } : <T>(x: T) => string
88+
>foo : <T>(x: T) => any
89+
><T>(x: T) => { var a = x['toString'](); // should be string return a + x.toString(); } : <T>(x: T) => any
9090
>x : T
9191

9292
var a = x['toString'](); // should be string
93-
>a : string
94-
>x['toString']() : string
95-
>x['toString'] : () => string
93+
>a : any
94+
>x['toString']() : any
95+
>x['toString'] : any
9696
>x : T
9797
>'toString' : "toString"
9898

9999
return a + x.toString();
100-
>a + x.toString() : string
101-
>a : string
102-
>x.toString() : string
103-
>x.toString : () => string
100+
>a + x.toString() : any
101+
>a : any
102+
>x.toString() : any
103+
>x.toString : any
104104
>x : T
105-
>toString : () => string
105+
>toString : any
106106
}
107107
}
108108

109109
var r4 = b.foo(1);
110-
>r4 : string
111-
>b.foo(1) : string
112-
>b.foo : <T>(x: T) => string
113-
>b : { foo: <T>(x: T) => string; }
114-
>foo : <T>(x: T) => string
110+
>r4 : any
111+
>b.foo(1) : any
112+
>b.foo : <T>(x: T) => any
113+
>b : { foo: <T>(x: T) => any; }
114+
>foo : <T>(x: T) => any
115115
>1 : 1
116116

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
tests/cases/compiler/staticAnonymousTypeNotReferencingTypeParameter.ts(67,42): error TS2339: Property 'toString' does not exist on type 'T'.
2+
3+
4+
==== tests/cases/compiler/staticAnonymousTypeNotReferencingTypeParameter.ts (1 errors) ====
5+
// This test case is a condensed version of Angular 2's ListWrapper. Prior to #7448
6+
// this would cause the compiler to run out of memory.
7+
8+
function outer<T>(x: T) {
9+
class Inner {
10+
static y: T = x;
11+
}
12+
return Inner;
13+
}
14+
let y: number = outer(5).y;
15+
16+
class ListWrapper2 {
17+
static clone<T>(dit: typeof ListWrapper2, array: T[]): T[] { return array.slice(0); }
18+
static reversed<T>(dit: typeof ListWrapper2, array: T[]): T[] {
19+
var a = ListWrapper2.clone(dit, array);
20+
return a;
21+
}
22+
}
23+
namespace tessst {
24+
/**
25+
* Iterates through 'array' by index and performs the callback on each element of array until the callback
26+
* returns a truthy value, then returns that value.
27+
* If no such value is found, the callback is applied to each element of array and undefined is returned.
28+
*/
29+
export function funkyFor<T, U>(array: T[], callback: (element: T, index: number) => U): U {
30+
if (array) {
31+
for (let i = 0, len = array.length; i < len; i++) {
32+
const result = callback(array[i], i);
33+
if (result) {
34+
return result;
35+
}
36+
}
37+
}
38+
return undefined;
39+
}
40+
}
41+
interface Scanner {
42+
scanRange<T>(start: number, length: number, callback: () => T): T;
43+
}
44+
class ListWrapper {
45+
// JS has no way to express a statically fixed size list, but dart does so we
46+
// keep both methods.
47+
static createFixedSize(dit: typeof ListWrapper, size: number): any[] { return new Array(size); }
48+
static createGrowableSize(dit: typeof ListWrapper, size: number): any[] { return new Array(size); }
49+
static clone<T>(dit: typeof ListWrapper, array: T[]): T[] { return array.slice(0); }
50+
static forEachWithIndex<T>(dit: typeof ListWrapper, array: T[], fn: (t: T, n: number) => void) {
51+
for (var i = 0; i < array.length; i++) {
52+
fn(array[i], i);
53+
}
54+
}
55+
static first<T>(dit: typeof ListWrapper, array: T[]): T {
56+
if (!array) return null;
57+
return array[0];
58+
}
59+
static last<T>(dit: typeof ListWrapper, array: T[]): T {
60+
if (!array || array.length == 0) return null;
61+
return array[array.length - 1];
62+
}
63+
static indexOf<T>(dit: typeof ListWrapper, array: T[], value: T, startIndex: number = 0): number {
64+
return array.indexOf(value, startIndex);
65+
}
66+
static contains<T>(dit: typeof ListWrapper, list: T[], el: T): boolean { return list.indexOf(el) !== -1; }
67+
static reversed<T>(dit: typeof ListWrapper, array: T[]): T[] {
68+
var a = ListWrapper.clone(dit, array);
69+
let scanner: Scanner;
70+
scanner.scanRange(3, 5, () => { });
71+
return tessst.funkyFor(array, t => t.toString()) ? a.reverse() : a;
72+
~~~~~~~~
73+
!!! error TS2339: Property 'toString' does not exist on type 'T'.
74+
}
75+
static concat(dit: typeof ListWrapper, a: any[], b: any[]): any[] { return a.concat(b); }
76+
static insert<T>(dit: typeof ListWrapper, list: T[], index: number, value: T) { list.splice(index, 0, value); }
77+
static removeAt<T>(dit: typeof ListWrapper, list: T[], index: number): T {
78+
var res = list[index];
79+
list.splice(index, 1);
80+
return res;
81+
}
82+
static removeAll<T>(dit: typeof ListWrapper, list: T[], items: T[]) {
83+
for (var i = 0; i < items.length; ++i) {
84+
var index = list.indexOf(items[i]);
85+
list.splice(index, 1);
86+
}
87+
}
88+
static remove<T>(dit: typeof ListWrapper, list: T[], el: T): boolean {
89+
var index = list.indexOf(el);
90+
if (index > -1) {
91+
list.splice(index, 1);
92+
return true;
93+
}
94+
return false;
95+
}
96+
static clear(dit: typeof ListWrapper, list: any[]) { list.length = 0; }
97+
static isEmpty(dit: typeof ListWrapper, list: any[]): boolean { return list.length == 0; }
98+
static fill(dit: typeof ListWrapper, list: any[], value: any, start: number = 0, end: number = null) {
99+
list.fill(value, start, end === null ? list.length : end);
100+
}
101+
static equals(dit: typeof ListWrapper, a: any[], b: any[]): boolean {
102+
if (a.length != b.length) return false;
103+
for (var i = 0; i < a.length; ++i) {
104+
if (a[i] !== b[i]) return false;
105+
}
106+
return true;
107+
}
108+
static slice<T>(dit: typeof ListWrapper, l: T[], from: number = 0, to: number = null): T[] {
109+
return l.slice(from, to === null ? undefined : to);
110+
}
111+
static splice<T>(dit: typeof ListWrapper, l: T[], from: number, length: number): T[] { return l.splice(from, length); }
112+
static sort<T>(dit: typeof ListWrapper, l: T[], compareFn?: (a: T, b: T) => number) {
113+
if (isPresent(compareFn)) {
114+
l.sort(compareFn);
115+
} else {
116+
l.sort();
117+
}
118+
}
119+
static toString<T>(dit: typeof ListWrapper, l: T[]): string { return l.toString(); }
120+
static toJSON<T>(dit: typeof ListWrapper, l: T[]): string { return JSON.stringify(l); }
121+
122+
static maximum<T>(dit: typeof ListWrapper, list: T[], predicate: (t: T) => number): T {
123+
if (list.length == 0) {
124+
return null;
125+
}
126+
var solution: T = null;
127+
var maxValue = -Infinity;
128+
for (var index = 0; index < list.length; index++) {
129+
var candidate = list[index];
130+
if (isBlank(candidate)) {
131+
continue;
132+
}
133+
var candidateValue = predicate(candidate);
134+
if (candidateValue > maxValue) {
135+
solution = candidate;
136+
maxValue = candidateValue;
137+
}
138+
}
139+
return solution;
140+
}
141+
}
142+
let cloned = ListWrapper.clone(ListWrapper, [1,2,3,4]);
143+
declare function isBlank(x: any): boolean;
144+
declare function isPresent<T>(compareFn?: (a: T, b: T) => number): boolean;
145+
interface Array<T> {
146+
fill(value: any, start: number, end: number): void;
147+
}

0 commit comments

Comments
 (0)