Skip to content

Commit 917d939

Browse files
committed
Accept baselines
1 parent b7b6ae3 commit 917d939

11 files changed

+264
-93
lines changed

src/compiler/transformers/declarations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ namespace ts {
10451045
if (canProdiceDiagnostic) {
10461046
getSymbolAccessibilityDiagnostic = oldDiag;
10471047
}
1048-
if (returnValue && (!isLateVisibilityPaintedStatement(input) || lateStatementReplacementMap.has("" + getNodeId(input)))) {
1048+
if (returnValue && (!isLateVisibilityPaintedStatement(input) || lateStatementReplacementMap.get("" + getNodeId(input)))) {
10491049
if (!resultHasExternalModuleIndicator && hasModifier(input, ModifierFlags.Export) && isSourceFile(input.parent)) {
10501050
// Exported top-level member indicates moduleness
10511051
resultHasExternalModuleIndicator = true;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
tests/cases/compiler/c.ts(4,14): error TS2415: Class 'D' incorrectly extends base class 'C'.
2+
Types have separate declarations of a private property '[x]'.
3+
4+
5+
==== tests/cases/compiler/a.ts (0 errors) ====
6+
export const x = Symbol();
7+
8+
==== tests/cases/compiler/b.ts (0 errors) ====
9+
import { x } from "./a";
10+
11+
export class C {
12+
private [x]: number = 1;
13+
}
14+
15+
==== tests/cases/compiler/c.ts (1 errors) ====
16+
import { x } from "./a";
17+
import { C } from "./b";
18+
19+
export class D extends C {
20+
~
21+
!!! error TS2415: Class 'D' incorrectly extends base class 'C'.
22+
!!! error TS2415: Types have separate declarations of a private property '[x]'.
23+
private [x]: 12 = 12;
24+
}
25+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//// [tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.ts] ////
2+
3+
//// [a.ts]
4+
export const x = Symbol();
5+
6+
//// [b.ts]
7+
import { x } from "./a";
8+
9+
export class C {
10+
private [x]: number = 1;
11+
}
12+
13+
//// [c.ts]
14+
import { x } from "./a";
15+
import { C } from "./b";
16+
17+
export class D extends C {
18+
private [x]: 12 = 12;
19+
}
20+
21+
22+
//// [a.js]
23+
"use strict";
24+
exports.__esModule = true;
25+
exports.x = Symbol();
26+
//// [b.js]
27+
"use strict";
28+
exports.__esModule = true;
29+
var a_1 = require("./a");
30+
var C = /** @class */ (function () {
31+
function C() {
32+
this[_a] = 1;
33+
}
34+
return C;
35+
}());
36+
_a = a_1.x;
37+
exports.C = C;
38+
var _a;
39+
//// [c.js]
40+
"use strict";
41+
var __extends = (this && this.__extends) || (function () {
42+
var extendStatics = Object.setPrototypeOf ||
43+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45+
return function (d, b) {
46+
extendStatics(d, b);
47+
function __() { this.constructor = d; }
48+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
49+
};
50+
})();
51+
exports.__esModule = true;
52+
var a_1 = require("./a");
53+
var b_1 = require("./b");
54+
var D = /** @class */ (function (_super) {
55+
__extends(D, _super);
56+
function D() {
57+
var _this = _super !== null && _super.apply(this, arguments) || this;
58+
_this[_a] = 12;
59+
return _this;
60+
}
61+
return D;
62+
}(b_1.C));
63+
_a = a_1.x;
64+
exports.D = D;
65+
var _a;
66+
67+
68+
//// [a.d.ts]
69+
export declare const x: unique symbol;
70+
//// [b.d.ts]
71+
import { x } from "./a";
72+
export declare class C {
73+
private [x];
74+
}
75+
//// [c.d.ts]
76+
import { x } from "./a";
77+
import { C } from "./b";
78+
export declare class D extends C {
79+
private [x];
80+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/a.ts ===
2+
export const x = Symbol();
3+
>x : Symbol(x, Decl(a.ts, 0, 12))
4+
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
5+
6+
=== tests/cases/compiler/b.ts ===
7+
import { x } from "./a";
8+
>x : Symbol(x, Decl(b.ts, 0, 8))
9+
10+
export class C {
11+
>C : Symbol(C, Decl(b.ts, 0, 24))
12+
13+
private [x]: number = 1;
14+
>[x] : Symbol(C[x], Decl(b.ts, 2, 16))
15+
>x : Symbol(x, Decl(b.ts, 0, 8))
16+
}
17+
18+
=== tests/cases/compiler/c.ts ===
19+
import { x } from "./a";
20+
>x : Symbol(x, Decl(c.ts, 0, 8))
21+
22+
import { C } from "./b";
23+
>C : Symbol(C, Decl(c.ts, 1, 8))
24+
25+
export class D extends C {
26+
>D : Symbol(D, Decl(c.ts, 1, 24))
27+
>C : Symbol(C, Decl(c.ts, 1, 8))
28+
29+
private [x]: 12 = 12;
30+
>[x] : Symbol(D[x], Decl(c.ts, 3, 26))
31+
>x : Symbol(x, Decl(c.ts, 0, 8))
32+
}
33+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/a.ts ===
2+
export const x = Symbol();
3+
>x : unique symbol
4+
>Symbol() : unique symbol
5+
>Symbol : SymbolConstructor
6+
7+
=== tests/cases/compiler/b.ts ===
8+
import { x } from "./a";
9+
>x : unique symbol
10+
11+
export class C {
12+
>C : C
13+
14+
private [x]: number = 1;
15+
>[x] : number
16+
>x : unique symbol
17+
>1 : 1
18+
}
19+
20+
=== tests/cases/compiler/c.ts ===
21+
import { x } from "./a";
22+
>x : unique symbol
23+
24+
import { C } from "./b";
25+
>C : typeof C
26+
27+
export class D extends C {
28+
>D : D
29+
>C : C
30+
31+
private [x]: 12 = 12;
32+
>[x] : 12
33+
>x : unique symbol
34+
>12 : 12
35+
}
36+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts]
2+
const _data = Symbol('data');
3+
4+
export class User {
5+
private [_data] : any;
6+
};
7+
8+
9+
//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.js]
10+
"use strict";
11+
exports.__esModule = true;
12+
var _data = Symbol('data');
13+
var User = /** @class */ (function () {
14+
function User() {
15+
}
16+
return User;
17+
}());
18+
exports.User = User;
19+
;
20+
21+
22+
//// [declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.d.ts]
23+
declare const _data: unique symbol;
24+
export declare class User {
25+
private [_data];
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts ===
2+
const _data = Symbol('data');
3+
>_data : Symbol(_data, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 5))
4+
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
5+
6+
export class User {
7+
>User : Symbol(User, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 29))
8+
9+
private [_data] : any;
10+
>[_data] : Symbol(User[_data], Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 2, 19))
11+
>_data : Symbol(_data, Decl(declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts, 0, 5))
12+
13+
};
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/declarationEmitPrivateSymbolCausesVarDeclarationToBeEmitted.ts ===
2+
const _data = Symbol('data');
3+
>_data : unique symbol
4+
>Symbol('data') : unique symbol
5+
>Symbol : SymbolConstructor
6+
>'data' : "data"
7+
8+
export class User {
9+
>User : User
10+
11+
private [_data] : any;
12+
>[_data] : any
13+
>_data : unique symbol
14+
15+
};
16+

tests/baselines/reference/dynamicNamesErrors.errors.txt

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,9 @@ tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not
77
tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not assignable to type 'T2'.
88
Types of property '[c0]' are incompatible.
99
Type 'number' is not assignable to type 'string'.
10-
tests/cases/compiler/dynamicNamesErrors.ts(33,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
11-
tests/cases/compiler/dynamicNamesErrors.ts(34,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
12-
tests/cases/compiler/dynamicNamesErrors.ts(38,13): error TS4028: Public static property '[x]' of exported class has or is using private name 'x'.
13-
tests/cases/compiler/dynamicNamesErrors.ts(39,13): error TS4097: Public static method '[y]' of exported class has or is using private name 'y'.
14-
tests/cases/compiler/dynamicNamesErrors.ts(40,17): error TS4028: Public static property '[z]' of exported class has or is using private name 'z'.
15-
tests/cases/compiler/dynamicNamesErrors.ts(41,17): error TS4028: Public static property '[w]' of exported class has or is using private name 'w'.
16-
tests/cases/compiler/dynamicNamesErrors.ts(43,6): error TS4031: Public property '[x]' of exported class has or is using private name 'x'.
17-
tests/cases/compiler/dynamicNamesErrors.ts(44,6): error TS4100: Public method '[y]' of exported class has or is using private name 'y'.
18-
tests/cases/compiler/dynamicNamesErrors.ts(45,10): error TS4031: Public property '[z]' of exported class has or is using private name 'z'.
19-
tests/cases/compiler/dynamicNamesErrors.ts(46,10): error TS4031: Public property '[w]' of exported class has or is using private name 'w'.
20-
tests/cases/compiler/dynamicNamesErrors.ts(50,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
21-
tests/cases/compiler/dynamicNamesErrors.ts(51,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
22-
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'.
23-
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'.
24-
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'.
25-
tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'.
2610

2711

28-
==== tests/cases/compiler/dynamicNamesErrors.ts (21 errors) ====
12+
==== tests/cases/compiler/dynamicNamesErrors.ts (5 errors) ====
2913
const c0 = "1";
3014
const c1 = 1;
3115

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

7458
export interface InterfaceMemberVisibility {
7559
[x]: number;
76-
~
77-
!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
7860
[y](): number;
79-
~
80-
!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
8161
}
8262

8363
export class ClassMemberVisibility {
8464
static [x]: number;
85-
~
86-
!!! error TS4028: Public static property '[x]' of exported class has or is using private name 'x'.
8765
static [y](): number { return 0; }
88-
~
89-
!!! error TS4097: Public static method '[y]' of exported class has or is using private name 'y'.
9066
static get [z](): number { return 0; }
91-
~
92-
!!! error TS4028: Public static property '[z]' of exported class has or is using private name 'z'.
9367
static set [w](value: number) { }
94-
~
95-
!!! error TS4028: Public static property '[w]' of exported class has or is using private name 'w'.
9668

9769
[x]: number;
98-
~
99-
!!! error TS4031: Public property '[x]' of exported class has or is using private name 'x'.
10070
[y](): number { return 0; }
101-
~
102-
!!! error TS4100: Public method '[y]' of exported class has or is using private name 'y'.
10371
get [z](): number { return 0; }
104-
~
105-
!!! error TS4031: Public property '[z]' of exported class has or is using private name 'z'.
10672
set [w](value: number) { }
107-
~
108-
!!! error TS4031: Public property '[w]' of exported class has or is using private name 'w'.
10973
}
11074

11175
export type ObjectTypeVisibility = {
11276
[x]: number;
113-
~
114-
!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'.
11577
[y](): number;
116-
~
117-
!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'.
11878
};
11979

12080
export const ObjectLiteralVisibility = {
121-
~~~~~~~~~~~~~~~~~~~~~~~
122-
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'.
123-
~~~~~~~~~~~~~~~~~~~~~~~
124-
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'.
125-
~~~~~~~~~~~~~~~~~~~~~~~
126-
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'.
127-
~~~~~~~~~~~~~~~~~~~~~~~
128-
!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'.
12981
[x]: 0,
13082
[y](): number { return 0; },
13183
get [z](): number { return 0; },

tests/baselines/reference/dynamicNamesErrors.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,34 @@ exports.ObjectLiteralVisibility = {
8787
get [z]() { return 0; },
8888
set [w](value) { },
8989
};
90+
91+
92+
//// [dynamicNamesErrors.d.ts]
93+
declare const x: unique symbol;
94+
declare const y: unique symbol;
95+
declare const z: unique symbol;
96+
declare const w: unique symbol;
97+
export interface InterfaceMemberVisibility {
98+
[x]: number;
99+
[y](): number;
100+
}
101+
export declare class ClassMemberVisibility {
102+
static [x]: number;
103+
static [y](): number;
104+
static readonly [z]: number;
105+
static [w]: number;
106+
[x]: number;
107+
[y](): number;
108+
readonly [z]: number;
109+
[w]: number;
110+
}
111+
export declare type ObjectTypeVisibility = {
112+
[x]: number;
113+
[y](): number;
114+
};
115+
export declare const ObjectLiteralVisibility: {
116+
[x]: number;
117+
[y](): number;
118+
readonly [z]: number;
119+
[w]: number;
120+
};

0 commit comments

Comments
 (0)