Accepted baselines.

This commit is contained in:
Daniel Rosenwasser
2016-02-12 14:12:56 -08:00
parent f235b85ca1
commit 74b1e3f446
14 changed files with 298 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,10 @@
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
export function f(x: any): x is number {
>f : Symbol(f, Decl(declarationEmitIdentifierPredicates01.ts, 0, 0))
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
return typeof x === "number";
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
}

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
export function f(x: any): x is number {
>f : (x: any) => x is number
>x : any
>x : any
return typeof x === "number";
>typeof x === "number" : boolean
>typeof x : string
>x : any
>"number" : string
}

View File

@@ -0,0 +1,14 @@
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts(6,33): error TS4060: Return type of exported function has or is using private name 'I'.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts (1 errors) ====
interface I {
a: number;
}
export function f(x: any): x is I {
~
!!! error TS4060: Return type of exported function has or is using private name 'I'.
return typeof x.a === "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,19 @@
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
export class C {
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
m(): this is D {
>m : Symbol(m, Decl(declarationEmitThisPredicates01.ts, 1, 16))
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
return this instanceof D;
>this : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
}
}
export class D extends C {
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
}

View File

@@ -0,0 +1,20 @@
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
export class C {
>C : C
m(): this is D {
>m : () => this is D
>D : D
return this instanceof D;
>this instanceof D : boolean
>this : this
>D : typeof D
}
}
export class D extends C {
>D : D
>C : C
}

View File

@@ -0,0 +1,19 @@
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.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (1 errors) ====
export interface Foo {
a: string;
b: number;
c: boolean;
}
export const obj = {
m(): this is Foo {
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
let dis = this as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}

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,15 @@
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'.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts (1 errors) ====
export class C {
m(): this is D {
~
!!! error TS4055: Return type of public method from exported class has or is using private name 'D'.
return this instanceof D;
}
}
class D extends C {
}

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,22 @@
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
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.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ====
interface Foo {
a: string;
b: number;
c: boolean;
}
export const obj = {
~~~
!!! error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
m(): this is Foo {
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
let dis = this as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}

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;
}
};