Added the accidentally-ignored js files.

This commit is contained in:
Daniel Rosenwasser 2016-02-12 17:39:46 -08:00
parent 1e849f895c
commit e29be4b2d9
9 changed files with 208 additions and 0 deletions

View file

@ -0,0 +1,16 @@
//// [declarationEmitIdentifierPredicates01.ts]
export function f(x: any): x is number {
return typeof x === "number";
}
//// [declarationEmitIdentifierPredicates01.js]
"use strict";
function f(x) {
return typeof x === "number";
}
exports.f = f;
//// [declarationEmitIdentifierPredicates01.d.ts]
export declare function f(x: any): x is number;

View file

@ -0,0 +1,16 @@
//// [declarationEmitIdentifierPredicatesWithPrivateName01.ts]
interface I {
a: number;
}
export function f(x: any): x is I {
return typeof x.a === "number";
}
//// [declarationEmitIdentifierPredicatesWithPrivateName01.js]
"use strict";
function f(x) {
return typeof x.a === "number";
}
exports.f = f;

View file

@ -0,0 +1,43 @@
//// [declarationEmitThisPredicates01.ts]
export class C {
m(): this is D {
return this instanceof D;
}
}
export class D extends C {
}
//// [declarationEmitThisPredicates01.js]
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var C = (function () {
function C() {
}
C.prototype.m = function () {
return this instanceof D;
};
return C;
}());
exports.C = C;
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
return D;
}(C));
exports.D = D;
//// [declarationEmitThisPredicates01.d.ts]
export declare class C {
m(): this is D;
}
export declare class D extends C {
}

View file

@ -0,0 +1,34 @@
//// [declarationEmitThisPredicates02.ts]
export interface Foo {
a: string;
b: number;
c: boolean;
}
export const obj = {
m(): this is Foo {
let dis = this as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}
//// [declarationEmitThisPredicates02.js]
"use strict";
exports.obj = {
m: function () {
var dis = this;
return dis.a != null && dis.b != null && dis.c != null;
}
};
//// [declarationEmitThisPredicates02.d.ts]
export interface Foo {
a: string;
b: number;
c: boolean;
}
export declare const obj: {
m(): this is Foo;
};

View file

@ -0,0 +1,34 @@
//// [declarationEmitThisPredicatesWithPrivateName01.ts]
export class C {
m(): this is D {
return this instanceof D;
}
}
class D extends C {
}
//// [declarationEmitThisPredicatesWithPrivateName01.js]
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var C = (function () {
function C() {
}
C.prototype.m = function () {
return this instanceof D;
};
return C;
}());
exports.C = C;
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
return D;
}(C));

View file

@ -0,0 +1,23 @@
//// [declarationEmitThisPredicatesWithPrivateName02.ts]
interface Foo {
a: string;
b: number;
c: boolean;
}
export const obj = {
m(): this is Foo {
let dis = this as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}
//// [declarationEmitThisPredicatesWithPrivateName02.js]
"use strict";
exports.obj = {
m: function () {
var dis = this;
return dis.a != null && dis.b != null && dis.c != null;
}
};

View file

@ -0,0 +1,26 @@
//// [typeGuardOfFormFunctionEquality.ts]
declare function isString1(a: number, b: Object): b is string;
declare function isString2(a: Object): a is string;
switch (isString1(0, "")) {
case isString2(""):
default:
}
var x = isString1(0, "") === isString2("");
function isString3(a: number, b: number, c: Object): c is string {
return isString1(0, c);
}
//// [typeGuardOfFormFunctionEquality.js]
switch (isString1(0, "")) {
case isString2(""):
default:
}
var x = isString1(0, "") === isString2("");
function isString3(a, b, c) {
return isString1(0, c);
}

View file

@ -0,0 +1,10 @@
//// [typePredicateOnVariableDeclaration01.ts]
var x: this is string;
//// [typePredicateOnVariableDeclaration01.js]
var x;
//// [typePredicateOnVariableDeclaration01.d.ts]
declare var x: this is string;

View file

@ -0,0 +1,6 @@
//// [typePredicateOnVariableDeclaration02.ts]
var y: z is number;
//// [typePredicateOnVariableDeclaration02.js]
var y = is, number;