Skip to content

Commit

Permalink
Accept baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Mar 22, 2018
1 parent b7b6ae3 commit 917d939
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ namespace ts {
if (canProdiceDiagnostic) {
getSymbolAccessibilityDiagnostic = oldDiag;
}
if (returnValue && (!isLateVisibilityPaintedStatement(input) || lateStatementReplacementMap.has("" + getNodeId(input)))) {
if (returnValue && (!isLateVisibilityPaintedStatement(input) || lateStatementReplacementMap.get("" + getNodeId(input)))) {
if (!resultHasExternalModuleIndicator && hasModifier(input, ModifierFlags.Export) && isSourceFile(input.parent)) {
// Exported top-level member indicates moduleness
resultHasExternalModuleIndicator = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests/cases/compiler/c.ts(4,14): error TS2415: Class 'D' incorrectly extends base class 'C'.
Types have separate declarations of a private property '[x]'.


==== tests/cases/compiler/a.ts (0 errors) ====
export const x = Symbol();

==== tests/cases/compiler/b.ts (0 errors) ====
import { x } from "./a";

export class C {
private [x]: number = 1;
}

==== tests/cases/compiler/c.ts (1 errors) ====
import { x } from "./a";
import { C } from "./b";

export class D extends C {
~
!!! error TS2415: Class 'D' incorrectly extends base class 'C'.
!!! error TS2415: Types have separate declarations of a private property '[x]'.
private [x]: 12 = 12;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//// [tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.ts] ////

//// [a.ts]
export const x = Symbol();

//// [b.ts]
import { x } from "./a";

export class C {
private [x]: number = 1;
}

//// [c.ts]
import { x } from "./a";
import { C } from "./b";

export class D extends C {
private [x]: 12 = 12;
}


//// [a.js]
"use strict";
exports.__esModule = true;
exports.x = Symbol();
//// [b.js]
"use strict";
exports.__esModule = true;
var a_1 = require("./a");
var C = /** @class */ (function () {
function C() {
this[_a] = 1;
}
return C;
}());
_a = a_1.x;
exports.C = C;
var _a;
//// [c.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;
var a_1 = require("./a");
var b_1 = require("./b");
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this[_a] = 12;
return _this;
}
return D;
}(b_1.C));
_a = a_1.x;
exports.D = D;
var _a;


//// [a.d.ts]
export declare const x: unique symbol;
//// [b.d.ts]
import { x } from "./a";
export declare class C {
private [x];
}
//// [c.d.ts]
import { x } from "./a";
import { C } from "./b";
export declare class D extends C {
private [x];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
=== tests/cases/compiler/a.ts ===
export const x = Symbol();
>x : Symbol(x, Decl(a.ts, 0, 12))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))

=== tests/cases/compiler/b.ts ===
import { x } from "./a";
>x : Symbol(x, Decl(b.ts, 0, 8))

export class C {
>C : Symbol(C, Decl(b.ts, 0, 24))

private [x]: number = 1;
>[x] : Symbol(C[x], Decl(b.ts, 2, 16))
>x : Symbol(x, Decl(b.ts, 0, 8))
}

=== tests/cases/compiler/c.ts ===
import { x } from "./a";
>x : Symbol(x, Decl(c.ts, 0, 8))

import { C } from "./b";
>C : Symbol(C, Decl(c.ts, 1, 8))

export class D extends C {
>D : Symbol(D, Decl(c.ts, 1, 24))
>C : Symbol(C, Decl(c.ts, 1, 8))

private [x]: 12 = 12;
>[x] : Symbol(D[x], Decl(c.ts, 3, 26))
>x : Symbol(x, Decl(c.ts, 0, 8))
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
=== tests/cases/compiler/a.ts ===
export const x = Symbol();
>x : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor

=== tests/cases/compiler/b.ts ===
import { x } from "./a";
>x : unique symbol

export class C {
>C : C

private [x]: number = 1;
>[x] : number
>x : unique symbol
>1 : 1
}

=== tests/cases/compiler/c.ts ===
import { x } from "./a";
>x : unique symbol

import { C } from "./b";
>C : typeof C

export class D extends C {
>D : D
>C : C

private [x]: 12 = 12;
>[x] : 12
>x : unique symbol
>12 : 12
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts]
const _data = Symbol('data');

export class User {
private [_data] : any;
};


//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.js]
"use strict";
exports.__esModule = true;
var _data = Symbol('data');
var User = /** @class */ (function () {
function User() {
}
return User;
}());
exports.User = User;
;


//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.d.ts]
declare const _data: unique symbol;
export declare class User {
private [_data];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts ===
const _data = Symbol('data');
>_data : Symbol(_data, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 5))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))

export class User {
>User : Symbol(User, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 29))

private [_data] : any;
>[_data] : Symbol(User[_data], Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 2, 19))
>_data : Symbol(_data, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 5))

};

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts ===
const _data = Symbol('data');
>_data : unique symbol
>Symbol('data') : unique symbol
>Symbol : SymbolConstructor
>'data' : "data"

export class User {
>User : User

private [_data] : any;
>[_data] : any
>_data : unique symbol

};

50 changes: 1 addition & 49 deletions tests/baselines/reference/dynamicNamesErrors.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,9 @@ tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not
tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not assignable to type 'T2'.
Types of property '[c0]' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/dynamicNamesErrors.ts(33,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
tests/cases/compiler/dynamicNamesErrors.ts(34,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
tests/cases/compiler/dynamicNamesErrors.ts(38,13): error TS4028: Public static property '[x]' of exported class has or is using private name 'x'.
tests/cases/compiler/dynamicNamesErrors.ts(39,13): error TS4097: Public static method '[y]' of exported class has or is using private name 'y'.
tests/cases/compiler/dynamicNamesErrors.ts(40,17): error TS4028: Public static property '[z]' of exported class has or is using private name 'z'.
tests/cases/compiler/dynamicNamesErrors.ts(41,17): error TS4028: Public static property '[w]' of exported class has or is using private name 'w'.
tests/cases/compiler/dynamicNamesErrors.ts(43,6): error TS4031: Public property '[x]' of exported class has or is using private name 'x'.
tests/cases/compiler/dynamicNamesErrors.ts(44,6): error TS4100: Public method '[y]' of exported class has or is using private name 'y'.
tests/cases/compiler/dynamicNamesErrors.ts(45,10): error TS4031: Public property '[z]' of exported class has or is using private name 'z'.
tests/cases/compiler/dynamicNamesErrors.ts(46,10): error TS4031: Public property '[w]' of exported class has or is using private name 'w'.
tests/cases/compiler/dynamicNamesErrors.ts(50,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
tests/cases/compiler/dynamicNamesErrors.ts(51,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'.
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'.
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'.
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'.


==== tests/cases/compiler/dynamicNamesErrors.ts (21 errors) ====
==== tests/cases/compiler/dynamicNamesErrors.ts (5 errors) ====
const c0 = "1";
const c1 = 1;

Expand Down Expand Up @@ -73,59 +57,27 @@ tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variab

export interface InterfaceMemberVisibility {
[x]: number;
~
!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
[y](): number;
~
!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
}

export class ClassMemberVisibility {
static [x]: number;
~
!!! error TS4028: Public static property '[x]' of exported class has or is using private name 'x'.
static [y](): number { return 0; }
~
!!! error TS4097: Public static method '[y]' of exported class has or is using private name 'y'.
static get [z](): number { return 0; }
~
!!! error TS4028: Public static property '[z]' of exported class has or is using private name 'z'.
static set [w](value: number) { }
~
!!! error TS4028: Public static property '[w]' of exported class has or is using private name 'w'.

[x]: number;
~
!!! error TS4031: Public property '[x]' of exported class has or is using private name 'x'.
[y](): number { return 0; }
~
!!! error TS4100: Public method '[y]' of exported class has or is using private name 'y'.
get [z](): number { return 0; }
~
!!! error TS4031: Public property '[z]' of exported class has or is using private name 'z'.
set [w](value: number) { }
~
!!! error TS4031: Public property '[w]' of exported class has or is using private name 'w'.
}

export type ObjectTypeVisibility = {
[x]: number;
~
!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
[y](): number;
~
!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
};

export const ObjectLiteralVisibility = {
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'.
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'.
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'.
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'.
[x]: 0,
[y](): number { return 0; },
get [z](): number { return 0; },
Expand Down
31 changes: 31 additions & 0 deletions tests/baselines/reference/dynamicNamesErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,34 @@ exports.ObjectLiteralVisibility = {
get [z]() { return 0; },
set [w](value) { },
};


//// [dynamicNamesErrors.d.ts]
declare const x: unique symbol;
declare const y: unique symbol;
declare const z: unique symbol;
declare const w: unique symbol;
export interface InterfaceMemberVisibility {
[x]: number;
[y](): number;
}
export declare class ClassMemberVisibility {
static [x]: number;
static [y](): number;
static readonly [z]: number;
static [w]: number;
[x]: number;
[y](): number;
readonly [z]: number;
[w]: number;
}
export declare type ObjectTypeVisibility = {
[x]: number;
[y](): number;
};
export declare const ObjectLiteralVisibility: {
[x]: number;
[y](): number;
readonly [z]: number;
[w]: number;
};
Loading

0 comments on commit 917d939

Please sign in to comment.