Skip to content

Commit 23f6c67

Browse files
Accept new baseline.
1 parent d2ab6fc commit 23f6c67

9 files changed

+98
-49
lines changed

src/compiler/transformers/classFields.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ namespace ts {
337337
if (!shouldTransformPrivateElements && isPrivateIdentifier(node.name)) {
338338
// Initializer is elided as the field is initialized in transformConstructor.
339339
// We include initalizers for static private fields as there is no simple way to do this emit,
340-
// and nobody is relying on the old assignment semantics for private static fields.
340+
// and nobody is relying on the old assignment semantics for private static fields.
341341
return factory.updatePropertyDeclaration(
342342
node,
343343
/*decorators*/ undefined,
@@ -796,7 +796,7 @@ namespace ts {
796796
pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
797797
}
798798

799-
if (pendingStatements ) {
799+
if (pendingStatements) {
800800
if (some(staticProperties)) {
801801
addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node));
802802
}

tests/baselines/reference/privateNameAndAny.errors.txt

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(5,15): error TS2339: Property '#bar' does not exist on type 'any'.
2-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(9,9): error TS2571: Object is of type 'unknown'.
3-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(10,9): error TS2571: Object is of type 'unknown'.
4-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(10,15): error TS2339: Property '#bar' does not exist on type 'any'.
5-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(11,9): error TS2571: Object is of type 'unknown'.
6-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(14,15): error TS2339: Property '#foo' does not exist on type 'never'.
7-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(15,15): error TS2339: Property '#bar' does not exist on type 'never'.
8-
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(16,15): error TS2339: Property '#foo' does not exist on type 'never'.
1+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(8,15): error TS2339: Property '#bar' does not exist on type 'any'.
2+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(9,15): error TS2339: Property '#bar' does not exist on type 'any'.
3+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(13,9): error TS2571: Object is of type 'unknown'.
4+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(14,9): error TS2571: Object is of type 'unknown'.
5+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(14,15): error TS2339: Property '#bar' does not exist on type 'any'.
6+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(15,9): error TS2571: Object is of type 'unknown'.
7+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(18,15): error TS2339: Property '#foo' does not exist on type 'never'.
8+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(19,15): error TS2339: Property '#bar' does not exist on type 'never'.
9+
tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts(20,15): error TS2339: Property '#foo' does not exist on type 'never'.
910

1011

11-
==== tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts (8 errors) ====
12+
==== tests/cases/conformance/classes/members/privateNames/privateNameAndAny.ts (9 errors) ====
1213
class A {
13-
#foo = true;
14+
#foo = true;
15+
static #baz = 10;
16+
static #m() {}
1417
method(thing: any) {
1518
thing.#foo; // OK
19+
thing.#m();
20+
thing.#bar;
21+
~~~~
22+
!!! error TS2339: Property '#bar' does not exist on type 'any'.
1623
thing.#bar; // Error
1724
~~~~
1825
!!! error TS2339: Property '#bar' does not exist on type 'any'.

tests/baselines/reference/privateNameAndAny.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
//// [privateNameAndAny.ts]
22
class A {
3-
#foo = true;
3+
#foo = true;
4+
static #baz = 10;
5+
static #m() {}
46
method(thing: any) {
57
thing.#foo; // OK
8+
thing.#m();
9+
thing.#bar;
610
thing.#bar; // Error
711
thing.#foo();
812
}
@@ -27,13 +31,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
2731
}
2832
return privateMap.get(receiver);
2933
};
30-
var _A_foo;
34+
var __classStaticPrivateMethodGet = (this && this.__classStaticPrivateMethodGet) || function (receiver, classConstructor, fn) {
35+
if (receiver !== classConstructor) {
36+
throw new TypeError("Private static access of wrong provenance");
37+
}
38+
return fn;
39+
};
40+
var _A_foo, _A_baz, _A_m;
3141
class A {
3242
constructor() {
3343
_A_foo.set(this, true);
3444
}
3545
method(thing) {
3646
__classPrivateFieldGet(thing, _A_foo); // OK
47+
__classStaticPrivateMethodGet(thing, A, _A_m).call(// OK
48+
thing);
49+
thing.;
3750
thing.; // Error
3851
__classPrivateFieldGet(thing, _A_foo).call(// Error
3952
thing);
@@ -49,5 +62,6 @@ class A {
4962
__classPrivateFieldGet(thing, _A_foo).call(thing);
5063
}
5164
}
52-
_A_foo = new WeakMap();
65+
_A_foo = new WeakMap(), _A_m = function _A_m() { };
66+
_A_baz = { value: 10 };
5367
;

tests/baselines/reference/privateNameAndAny.symbols

+28-16
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,59 @@
22
class A {
33
>A : Symbol(A, Decl(privateNameAndAny.ts, 0, 0))
44

5-
#foo = true;
5+
#foo = true;
66
>#foo : Symbol(A.#foo, Decl(privateNameAndAny.ts, 0, 9))
77

8+
static #baz = 10;
9+
>#baz : Symbol(A.#baz, Decl(privateNameAndAny.ts, 1, 16))
10+
11+
static #m() {}
12+
>#m : Symbol(A.#m, Decl(privateNameAndAny.ts, 2, 21))
13+
814
method(thing: any) {
9-
>method : Symbol(A.method, Decl(privateNameAndAny.ts, 1, 16))
10-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
15+
>method : Symbol(A.method, Decl(privateNameAndAny.ts, 3, 18))
16+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
1117

1218
thing.#foo; // OK
13-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
19+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
20+
21+
thing.#m();
22+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
23+
24+
thing.#bar;
25+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
1426

1527
thing.#bar; // Error
16-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
28+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
1729

1830
thing.#foo();
19-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 2, 11))
31+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 4, 11))
2032
}
2133
methodU(thing: unknown) {
22-
>methodU : Symbol(A.methodU, Decl(privateNameAndAny.ts, 6, 5))
23-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 7, 12))
34+
>methodU : Symbol(A.methodU, Decl(privateNameAndAny.ts, 10, 5))
35+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 11, 12))
2436

2537
thing.#foo;
26-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 7, 12))
38+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 11, 12))
2739

2840
thing.#bar;
29-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 7, 12))
41+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 11, 12))
3042

3143
thing.#foo();
32-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 7, 12))
44+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 11, 12))
3345
}
3446
methodN(thing: never) {
35-
>methodN : Symbol(A.methodN, Decl(privateNameAndAny.ts, 11, 5))
36-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 12, 12))
47+
>methodN : Symbol(A.methodN, Decl(privateNameAndAny.ts, 15, 5))
48+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 16, 12))
3749

3850
thing.#foo;
39-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 12, 12))
51+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 16, 12))
4052

4153
thing.#bar;
42-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 12, 12))
54+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 16, 12))
4355

4456
thing.#foo();
45-
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 12, 12))
57+
>thing : Symbol(thing, Decl(privateNameAndAny.ts, 16, 12))
4658
}
4759
};
4860

tests/baselines/reference/privateNameAndAny.types

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22
class A {
33
>A : A
44

5-
#foo = true;
5+
#foo = true;
66
>#foo : boolean
77
>true : true
88

9+
static #baz = 10;
10+
>#baz : number
11+
>10 : 10
12+
13+
static #m() {}
14+
>#m : () => void
15+
916
method(thing: any) {
1017
>method : (thing: any) => void
1118
>thing : any
1219

1320
thing.#foo; // OK
1421
>thing.#foo : any
22+
>thing : any
23+
24+
thing.#m();
25+
>thing.#m() : any
26+
>thing.#m : any
27+
>thing : any
28+
29+
thing.#bar;
30+
>thing.#bar : any
1531
>thing : any
1632

1733
thing.#bar; // Error

tests/baselines/reference/privateNameStaticAccessorsCallExpression.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class A {
7272
>this.#fieldFunc2`head${1}middle${2}tail` : void
7373
>this.#fieldFunc2 : (a: any, ...b: any[]) => void
7474
>this : typeof A
75-
>`head${1}middle${2}tail` : "head1middle2tail"
75+
>`head${1}middle${2}tail` : string
7676
>1 : 1
7777
>2 : 2
7878

@@ -83,7 +83,7 @@ class A {
8383
>this.getClass : () => typeof A
8484
>this : typeof A
8585
>getClass : () => typeof A
86-
>`test${1}and${2}` : "test1and2"
86+
>`test${1}and${2}` : string
8787
>1 : 1
8888
>2 : 2
8989
}

tests/baselines/reference/privateNameStaticFieldCallExpression.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class A {
7878
>A.#fieldFunc2`head${1}middle${2}tail` : void
7979
>A.#fieldFunc2 : (a: any, ...b: any[]) => void
8080
>A : typeof A
81-
>`head${1}middle${2}tail` : "head1middle2tail"
81+
>`head${1}middle${2}tail` : string
8282
>1 : 1
8383
>2 : 2
8484

@@ -89,7 +89,7 @@ class A {
8989
>this.getClass : () => typeof A
9090
>this : this
9191
>getClass : () => typeof A
92-
>`test${1}and${2}` : "test1and2"
92+
>`test${1}and${2}` : string
9393
>1 : 1
9494
>2 : 2
9595
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(4,12): error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
2-
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(5,11): error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
3-
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(6,11): error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
4-
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(7,18): error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
5-
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(9,11): error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
1+
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(4,12): error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
2+
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(5,11): error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
3+
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(6,11): error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
4+
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(7,18): error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
5+
tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts(9,11): error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
66

77

88
==== tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts (5 errors) ====
@@ -11,20 +11,20 @@ tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssi
1111
constructor(a: typeof A3, b: any) {
1212
A3.#method = () => {} // Error, not writable
1313
~~~~~~~
14-
!!! error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
14+
!!! error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
1515
a.#method = () => { }; // Error, not writable
1616
~~~~~~~
17-
!!! error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
17+
!!! error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
1818
b.#method = () => { } //Error, not writable
1919
~~~~~~~
20-
!!! error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
20+
!!! error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
2121
({ x: A3.#method } = { x: () => {}}); //Error, not writable
2222
~~~~~~~
23-
!!! error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
23+
!!! error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
2424
let x = A3.#method;
2525
b.#method++ //Error, not writable
2626
~~~~~~~
27-
!!! error TS2801: Cannot assign to private method '#method'. Private methods are not writable.
27+
!!! error TS2803: Cannot assign to private method '#method'. Private methods are not writable.
2828
}
2929
}
3030

tests/baselines/reference/privateNameStaticMethodCallExpression.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AA {
7171
>AA.#method2`head${1}middle${2}tail` : void
7272
>AA.#method2 : (a: any, ...b: any[]) => void
7373
>AA : typeof AA
74-
>`head${1}middle${2}tail` : "head1middle2tail"
74+
>`head${1}middle${2}tail` : string
7575
>1 : 1
7676
>2 : 2
7777

@@ -82,7 +82,7 @@ class AA {
8282
>AA.getClass : () => typeof AA
8383
>AA : typeof AA
8484
>getClass : () => typeof AA
85-
>`test${1}and${2}` : "test1and2"
85+
>`test${1}and${2}` : string
8686
>1 : 1
8787
>2 : 2
8888

@@ -120,7 +120,7 @@ class AA {
120120
>AA.getClass : () => typeof AA
121121
>AA : typeof AA
122122
>getClass : () => typeof AA
123-
>`head${1}middle${2}tail` : "head1middle2tail"
123+
>`head${1}middle${2}tail` : string
124124
>1 : 1
125125
>2 : 2
126126
}

0 commit comments

Comments
 (0)