Add more tests and update baselines

This commit is contained in:
Nathan Shively-Sanders 2017-05-22 14:57:56 -07:00
parent 860e8e88c8
commit ecaf44d474
5 changed files with 157 additions and 23 deletions

View file

@ -95,18 +95,12 @@ export declare var simpleExample: {
new (): {
tags(): void;
};
prototype: {
tags(): void;
};
getTags(): void;
};
export declare var circularReference: {
new (): {
tags(c: any): any;
};
prototype: {
tags(c: any): any;
};
getTags(c: {
tags(c: any): any;
}): {
@ -124,11 +118,6 @@ export declare function WithTags<T extends Constructor<FooItem>>(Base: T): {
foo(): void;
name?: string;
};
prototype: {
tags(): void;
foo(): void;
name?: string;
};
getTags(): void;
} & T;
declare const Test_base: {
@ -137,11 +126,6 @@ declare const Test_base: {
foo(): void;
name?: string;
};
prototype: {
tags(): void;
foo(): void;
name?: string;
};
getTags(): void;
} & typeof FooItem;
export declare class Test extends Test_base {

View file

@ -0,0 +1,41 @@
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'p' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'ps' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(16,17): error TS4094: Property 'property' of exported class expression may not be private or protected.
==== tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts (3 errors) ====
export var noPrivates = class {
~~~~~~~~~~
!!! error TS4094: Property 'p' of exported class expression may not be private or protected.
~~~~~~~~~~
!!! error TS4094: Property 'ps' of exported class expression may not be private or protected.
static getTags() { }
tags() { }
private static ps = -1
private p = 12
}
// altered repro from #15066 to add private property
export class FooItem {
foo(): void { }
name?: string;
private property = "capitalism"
}
export type Constructor<T> = new(...args: any[]) => T;
export function WithTags<T extends Constructor<FooItem>>(Base: T) {
~~~~~~~~
!!! error TS4094: Property 'property' of exported class expression may not be private or protected.
return class extends Base {
static getTags(): void { }
tags(): void { }
}
}
export class Test extends WithTags(FooItem) {}
const test = new Test();
Test.getTags()
test.tags();

View file

@ -0,0 +1,87 @@
//// [emitClassExpressionInDeclarationFile2.ts]
export var noPrivates = class {
static getTags() { }
tags() { }
private static ps = -1
private p = 12
}
// altered repro from #15066 to add private property
export class FooItem {
foo(): void { }
name?: string;
private property = "capitalism"
}
export type Constructor<T> = new(...args: any[]) => T;
export function WithTags<T extends Constructor<FooItem>>(Base: T) {
return class extends Base {
static getTags(): void { }
tags(): void { }
}
}
export class Test extends WithTags(FooItem) {}
const test = new Test();
Test.getTags()
test.tags();
//// [emitClassExpressionInDeclarationFile2.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
exports.noPrivates = (_a = (function () {
function class_1() {
this.p = 12;
}
class_1.getTags = function () { };
class_1.prototype.tags = function () { };
return class_1;
}()),
_a.ps = -1,
_a);
// altered repro from #15066 to add private property
var FooItem = (function () {
function FooItem() {
this.property = "capitalism";
}
FooItem.prototype.foo = function () { };
return FooItem;
}());
exports.FooItem = FooItem;
function WithTags(Base) {
return (function (_super) {
__extends(class_2, _super);
function class_2() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_2.getTags = function () { };
class_2.prototype.tags = function () { };
return class_2;
}(Base));
}
exports.WithTags = WithTags;
var Test = (function (_super) {
__extends(Test, _super);
function Test() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Test;
}(WithTags(FooItem)));
exports.Test = Test;
var test = new Test();
Test.getTags();
test.tags();
var _a;

View file

@ -2,19 +2,12 @@
export var simpleExample = class {
static getTags() { }
tags() { }
private static ps = -1
private p = 12
}
export var circularReference = class C {
static getTags(c: C): C { return c }
tags(c: C): C { return c }
}
class Base { }
export function foo() {
return class extends Base { }
}
// repro from #15066
export class FooItem {
foo(): void { }

View file

@ -0,0 +1,29 @@
// @declaration: true
export var noPrivates = class {
static getTags() { }
tags() { }
private static ps = -1
private p = 12
}
// altered repro from #15066 to add private property
export class FooItem {
foo(): void { }
name?: string;
private property = "capitalism"
}
export type Constructor<T> = new(...args: any[]) => T;
export function WithTags<T extends Constructor<FooItem>>(Base: T) {
return class extends Base {
static getTags(): void { }
tags(): void { }
}
}
export class Test extends WithTags(FooItem) {}
const test = new Test();
Test.getTags()
test.tags();