Skip to content

Commit f235b85

Browse files
Added tests for declaration emit.
1 parent 9e9f541 commit f235b85

6 files changed

+68
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
export function f(x: any): x is number {
5+
return typeof x === "number";
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
interface I {
5+
a: number;
6+
}
7+
8+
export function f(x: any): x is I {
9+
return typeof x.a === "number";
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
export class C {
5+
m(): this is D {
6+
return this instanceof D;
7+
}
8+
}
9+
10+
export class D extends C {
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
export interface Foo {
5+
a: string;
6+
b: number;
7+
c: boolean;
8+
}
9+
10+
export const obj = {
11+
m(): this is Foo {
12+
let dis = this as Foo;
13+
return dis.a != null && dis.b != null && dis.c != null;
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
export class C {
5+
m(): this is D {
6+
return this instanceof D;
7+
}
8+
}
9+
10+
class D extends C {
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
interface Foo {
5+
a: string;
6+
b: number;
7+
c: boolean;
8+
}
9+
10+
export const obj = {
11+
m(): this is Foo {
12+
let dis = this as Foo;
13+
return dis.a != null && dis.b != null && dis.c != null;
14+
}
15+
}

0 commit comments

Comments
 (0)