Skip to content

Commit 74b1e3f

Browse files
Accepted baselines.
1 parent f235b85 commit 74b1e3f

14 files changed

+298
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [declarationEmitIdentifierPredicates01.ts]
2+
3+
export function f(x: any): x is number {
4+
return typeof x === "number";
5+
}
6+
7+
//// [declarationEmitIdentifierPredicates01.js]
8+
"use strict";
9+
function f(x) {
10+
return typeof x === "number";
11+
}
12+
exports.f = f;
13+
14+
15+
//// [declarationEmitIdentifierPredicates01.d.ts]
16+
export declare function f(x: any): x is number;
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [declarationEmitIdentifierPredicatesWithPrivateName01.ts]
2+
3+
interface I {
4+
a: number;
5+
}
6+
7+
export function f(x: any): x is I {
8+
return typeof x.a === "number";
9+
}
10+
11+
//// [declarationEmitIdentifierPredicatesWithPrivateName01.js]
12+
"use strict";
13+
function f(x) {
14+
return typeof x.a === "number";
15+
}
16+
exports.f = f;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//// [declarationEmitThisPredicates01.ts]
2+
3+
export class C {
4+
m(): this is D {
5+
return this instanceof D;
6+
}
7+
}
8+
9+
export class D extends C {
10+
}
11+
12+
//// [declarationEmitThisPredicates01.js]
13+
"use strict";
14+
var __extends = (this && this.__extends) || function (d, b) {
15+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
16+
function __() { this.constructor = d; }
17+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18+
};
19+
var C = (function () {
20+
function C() {
21+
}
22+
C.prototype.m = function () {
23+
return this instanceof D;
24+
};
25+
return C;
26+
}());
27+
exports.C = C;
28+
var D = (function (_super) {
29+
__extends(D, _super);
30+
function D() {
31+
_super.apply(this, arguments);
32+
}
33+
return D;
34+
}(C));
35+
exports.D = D;
36+
37+
38+
//// [declarationEmitThisPredicates01.d.ts]
39+
export declare class C {
40+
m(): this is D;
41+
}
42+
export declare class D extends C {
43+
}
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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [declarationEmitThisPredicates02.ts]
2+
3+
export interface Foo {
4+
a: string;
5+
b: number;
6+
c: boolean;
7+
}
8+
9+
export const obj = {
10+
m(): this is Foo {
11+
let dis = this as Foo;
12+
return dis.a != null && dis.b != null && dis.c != null;
13+
}
14+
}
15+
16+
//// [declarationEmitThisPredicates02.js]
17+
"use strict";
18+
exports.obj = {
19+
m: function () {
20+
var dis = this;
21+
return dis.a != null && dis.b != null && dis.c != null;
22+
}
23+
};
24+
25+
26+
//// [declarationEmitThisPredicates02.d.ts]
27+
export interface Foo {
28+
a: string;
29+
b: number;
30+
c: boolean;
31+
}
32+
export declare const obj: {
33+
m(): this is Foo;
34+
};

0 commit comments

Comments
 (0)