Skip to content

Commit 1e849f8

Browse files
Accepted baselines.
1 parent 1e27606 commit 1e849f8

30 files changed

+469
-570
lines changed

tests/baselines/reference/arrayBufferIsViewNarrowsType.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var obj: Object;
44
>Object : Object
55

66
if (ArrayBuffer.isView(obj)) {
7-
>ArrayBuffer.isView(obj) : arg is ArrayBufferView
7+
>ArrayBuffer.isView(obj) : boolean
88
>ArrayBuffer.isView : (arg: any) => arg is ArrayBufferView
99
>ArrayBuffer : ArrayBufferConstructor
1010
>isView : (arg: any) => arg is ArrayBufferView
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
2+
3+
export function f(x: any): x is number {
4+
>f : Symbol(f, Decl(declarationEmitIdentifierPredicates01.ts, 0, 0))
5+
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
6+
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
7+
8+
return typeof x === "number";
9+
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
2+
3+
export function f(x: any): x is number {
4+
>f : (x: any) => x is number
5+
>x : any
6+
>x : any
7+
8+
return typeof x === "number";
9+
>typeof x === "number" : boolean
10+
>typeof x : string
11+
>x : any
12+
>"number" : string
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts(6,33): error TS4060: Return type of exported function has or is using private name 'I'.
2+
3+
4+
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts (1 errors) ====
5+
6+
interface I {
7+
a: number;
8+
}
9+
10+
export function f(x: any): x is I {
11+
~
12+
!!! error TS4060: Return type of exported function has or is using private name 'I'.
13+
return typeof x.a === "number";
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
2+
3+
export class C {
4+
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
5+
6+
m(): this is D {
7+
>m : Symbol(m, Decl(declarationEmitThisPredicates01.ts, 1, 16))
8+
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
9+
10+
return this instanceof D;
11+
>this : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
12+
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
13+
}
14+
}
15+
16+
export class D extends C {
17+
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
18+
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
2+
3+
export class C {
4+
>C : C
5+
6+
m(): this is D {
7+
>m : () => this is D
8+
>D : D
9+
10+
return this instanceof D;
11+
>this instanceof D : boolean
12+
>this : this
13+
>D : typeof D
14+
}
15+
}
16+
17+
export class D extends C {
18+
>D : D
19+
>C : C
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
2+
3+
4+
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (1 errors) ====
5+
6+
export interface Foo {
7+
a: string;
8+
b: number;
9+
c: boolean;
10+
}
11+
12+
export const obj = {
13+
m(): this is Foo {
14+
~~~~
15+
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
16+
let dis = this as Foo;
17+
return dis.a != null && dis.b != null && dis.c != null;
18+
}
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts(3,18): error TS4055: Return type of public method from exported class has or is using private name 'D'.
2+
3+
4+
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts (1 errors) ====
5+
6+
export class C {
7+
m(): this is D {
8+
~
9+
!!! error TS4055: Return type of public method from exported class has or is using private name 'D'.
10+
return this instanceof D;
11+
}
12+
}
13+
14+
class D extends C {
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
2+
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
3+
4+
5+
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ====
6+
7+
interface Foo {
8+
a: string;
9+
b: number;
10+
c: boolean;
11+
}
12+
13+
export const obj = {
14+
~~~
15+
!!! error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
16+
m(): this is Foo {
17+
~~~~
18+
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
19+
let dis = this as Foo;
20+
return dis.a != null && dis.b != null && dis.c != null;
21+
}
22+
}

tests/baselines/reference/isArray.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var maybeArray: number | number[];
44

55

66
if (Array.isArray(maybeArray)) {
7-
>Array.isArray(maybeArray) : arg is any[]
7+
>Array.isArray(maybeArray) : boolean
88
>Array.isArray : (arg: any) => arg is any[]
99
>Array : ArrayConstructor
1010
>isArray : (arg: any) => arg is any[]

tests/baselines/reference/stringLiteralCheckedInIf02.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function f(foo: T) {
3131
>T : ("a" | "b")[] | "a" | "b"
3232

3333
if (isS(foo)) {
34-
>isS(foo) : t is "a" | "b"
34+
>isS(foo) : boolean
3535
>isS : (t: ("a" | "b")[] | "a" | "b") => t is "a" | "b"
3636
>foo : ("a" | "b")[] | "a" | "b"
3737

tests/baselines/reference/stringLiteralTypesAsTags01.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let x: A = {
8888
}
8989

9090
if (hasKind(x, "A")) {
91-
>hasKind(x, "A") : entity is A
91+
>hasKind(x, "A") : boolean
9292
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
9393
>x : A
9494
>"A" : "A"
@@ -105,7 +105,7 @@ else {
105105

106106
if (!hasKind(x, "B")) {
107107
>!hasKind(x, "B") : boolean
108-
>hasKind(x, "B") : entity is B
108+
>hasKind(x, "B") : boolean
109109
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
110110
>x : A
111111
>"B" : "B"

tests/baselines/reference/stringLiteralTypesAsTags02.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let x: A = {
8282
}
8383

8484
if (hasKind(x, "A")) {
85-
>hasKind(x, "A") : entity is A
85+
>hasKind(x, "A") : boolean
8686
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
8787
>x : A
8888
>"A" : "A"
@@ -99,7 +99,7 @@ else {
9999

100100
if (!hasKind(x, "B")) {
101101
>!hasKind(x, "B") : boolean
102-
>hasKind(x, "B") : entity is B
102+
>hasKind(x, "B") : boolean
103103
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
104104
>x : A
105105
>"B" : "B"

tests/baselines/reference/stringLiteralTypesAsTags03.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let x: A = {
8585
}
8686

8787
if (hasKind(x, "A")) {
88-
>hasKind(x, "A") : entity is A
88+
>hasKind(x, "A") : boolean
8989
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
9090
>x : A
9191
>"A" : "A"
@@ -102,7 +102,7 @@ else {
102102

103103
if (!hasKind(x, "B")) {
104104
>!hasKind(x, "B") : boolean
105-
>hasKind(x, "B") : entity is B
105+
>hasKind(x, "B") : boolean
106106
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
107107
>x : A
108108
>"B" : "B"

tests/baselines/reference/stringLiteralTypesTypePredicates01.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var x: Kind = "A";
3636
>"A" : "A"
3737

3838
if (kindIs(x, "A")) {
39-
>kindIs(x, "A") : kind is "A"
39+
>kindIs(x, "A") : boolean
4040
>kindIs : { (kind: "A" | "B", is: "A"): kind is "A"; (kind: "A" | "B", is: "B"): kind is "B"; }
4141
>x : "A" | "B"
4242
>"A" : "A"
@@ -53,7 +53,7 @@ else {
5353

5454
if (!kindIs(x, "B")) {
5555
>!kindIs(x, "B") : boolean
56-
>kindIs(x, "B") : kind is "B"
56+
>kindIs(x, "B") : boolean
5757
>kindIs : { (kind: "A" | "B", is: "A"): kind is "A"; (kind: "A" | "B", is: "B"): kind is "B"; }
5858
>x : "A" | "B"
5959
>"B" : "B"

tests/baselines/reference/typeGuardFunction.types

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var b: B;
5454

5555
// Basic
5656
if (isC(a)) {
57-
>isC(a) : p1 is C
57+
>isC(a) : boolean
5858
>isC : (p1: any) => p1 is C
5959
>a : A
6060

@@ -70,7 +70,7 @@ var subType: C;
7070
>C : C
7171

7272
if(isA(subType)) {
73-
>isA(subType) : p1 is A
73+
>isA(subType) : boolean
7474
>isA : (p1: any) => p1 is A
7575
>subType : C
7676

@@ -87,7 +87,7 @@ var union: A | B;
8787
>B : B
8888

8989
if(isA(union)) {
90-
>isA(union) : p1 is A
90+
>isA(union) : boolean
9191
>isA : (p1: any) => p1 is A
9292
>union : A | B
9393

@@ -118,7 +118,7 @@ declare function isC_multipleParams(p1, p2): p1 is C;
118118
>C : C
119119

120120
if (isC_multipleParams(a, 0)) {
121-
>isC_multipleParams(a, 0) : p1 is C
121+
>isC_multipleParams(a, 0) : boolean
122122
>isC_multipleParams : (p1: any, p2: any) => p1 is C
123123
>a : A
124124
>0 : number
@@ -197,7 +197,7 @@ declare function acceptingBoolean(a: boolean);
197197
acceptingBoolean(isA(a));
198198
>acceptingBoolean(isA(a)) : any
199199
>acceptingBoolean : (a: boolean) => any
200-
>isA(a) : p1 is A
200+
>isA(a) : boolean
201201
>isA : (p1: any) => p1 is A
202202
>a : A
203203

@@ -223,8 +223,8 @@ let union2: C | B;
223223
let union3: boolean | B = isA(union2) || union2;
224224
>union3 : boolean | B
225225
>B : B
226-
>isA(union2) || union2 : p1 is A | B
227-
>isA(union2) : p1 is A
226+
>isA(union2) || union2 : boolean | B
227+
>isA(union2) : boolean
228228
>isA : (p1: any) => p1 is A
229229
>union2 : C | B
230230
>union2 : B

tests/baselines/reference/typeGuardFunctionErrors.errors.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'.
2-
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'x is A'.
2+
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'.
33
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'.
44
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected.
55
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'.
@@ -43,9 +43,13 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22)
4343
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22): error TS2304: Cannot find name 'is'.
4444
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected.
4545
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected.
46+
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods.
4647
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'.
4748
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
49+
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
50+
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
4851
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value.
52+
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods.
4953
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS2304: Cannot find name 'p1'.
5054
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS1005: ';' expected.
5155
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS2304: Cannot find name 'is'.
@@ -57,7 +61,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34
5761
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
5862

5963

60-
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (50 errors) ====
64+
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (54 errors) ====
6165

6266
class A {
6367
~
@@ -76,7 +80,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
7680
function hasANonBooleanReturnStatement(x): x is A {
7781
return '';
7882
~~
79-
!!! error TS2322: Type 'string' is not assignable to type 'x is A'.
83+
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
8084
}
8185

8286
function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A {
@@ -245,16 +249,22 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
245249
// Non-compatiable type predicate positions for signature declarations
246250
class D {
247251
constructor(p1: A): p1 is C {
252+
~~~~~~~
253+
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
248254
return true;
249255
~~~~
250256
!!! error TS2322: Type 'boolean' is not assignable to type 'D'.
251257
~~~~
252258
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
253259
}
254260
get m1(p1: A): p1 is C {
261+
~~~~~~~
262+
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
255263
return true;
256264
}
257265
set m2(p1: A): p1 is C {
266+
~~~~~~~
267+
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
258268
return true;
259269
~~~~
260270
!!! error TS2408: Setters cannot return a value.
@@ -263,6 +273,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
263273

264274
interface I1 {
265275
new (p1: A): p1 is C;
276+
~~~~~~~
277+
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
266278
}
267279

268280
interface I2 {

tests/baselines/reference/typeGuardFunctionGenerics.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ let test1: boolean = funA(isB);
100100
>isB : (p1: any) => p1 is B
101101

102102
if (funB(retC, a)) {
103-
>funB(retC, a) : p2 is C
103+
>funB(retC, a) : boolean
104104
>funB : <T>(p1: (p1: any) => T, p2: any) => p2 is T
105105
>retC : (x: any) => C
106106
>a : A
@@ -118,7 +118,7 @@ let test2: B = funC(isB);
118118
>isB : (p1: any) => p1 is B
119119

120120
if (funD(isC, a)) {
121-
>funD(isC, a) : p2 is C
121+
>funD(isC, a) : boolean
122122
>funD : <T>(p1: (p1: any) => p1 is T, p2: any) => p2 is T
123123
>isC : (p1: any) => p1 is C
124124
>a : A

0 commit comments

Comments
 (0)