Skip to content

Commit e29be4b

Browse files
Added the accidentally-ignored js files.
1 parent 1e849f8 commit e29be4b

9 files changed

+208
-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: 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: 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+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [declarationEmitThisPredicatesWithPrivateName01.ts]
2+
3+
export class C {
4+
m(): this is D {
5+
return this instanceof D;
6+
}
7+
}
8+
9+
class D extends C {
10+
}
11+
12+
//// [declarationEmitThisPredicatesWithPrivateName01.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));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [declarationEmitThisPredicatesWithPrivateName02.ts]
2+
3+
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+
//// [declarationEmitThisPredicatesWithPrivateName02.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+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [typeGuardOfFormFunctionEquality.ts]
2+
declare function isString1(a: number, b: Object): b is string;
3+
4+
declare function isString2(a: Object): a is string;
5+
6+
switch (isString1(0, "")) {
7+
case isString2(""):
8+
default:
9+
}
10+
11+
var x = isString1(0, "") === isString2("");
12+
13+
function isString3(a: number, b: number, c: Object): c is string {
14+
return isString1(0, c);
15+
}
16+
17+
18+
//// [typeGuardOfFormFunctionEquality.js]
19+
switch (isString1(0, "")) {
20+
case isString2(""):
21+
default:
22+
}
23+
var x = isString1(0, "") === isString2("");
24+
function isString3(a, b, c) {
25+
return isString1(0, c);
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [typePredicateOnVariableDeclaration01.ts]
2+
3+
var x: this is string;
4+
5+
//// [typePredicateOnVariableDeclaration01.js]
6+
var x;
7+
8+
9+
//// [typePredicateOnVariableDeclaration01.d.ts]
10+
declare var x: this is string;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [typePredicateOnVariableDeclaration02.ts]
2+
3+
var y: z is number;
4+
5+
//// [typePredicateOnVariableDeclaration02.js]
6+
var y = is, number;

0 commit comments

Comments
 (0)