-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(48487): allow using private names as the self-assignment entity name
- Loading branch information
1 parent
e25f04a
commit a4c3ebe
Showing
9 changed files
with
216 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/typeFromPrivatePropertyAssignment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// [typeFromPrivatePropertyAssignment.ts] | ||
type Foo = { foo?: string }; | ||
|
||
class C { | ||
#a?: Foo; | ||
#b?: Foo; | ||
|
||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} | ||
|
||
|
||
//// [typeFromPrivatePropertyAssignment.js] | ||
class C { | ||
#a; | ||
#b; | ||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/typeFromPrivatePropertyAssignment.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignment.ts === | ||
type Foo = { foo?: string }; | ||
>Foo : Symbol(Foo, Decl(typeFromPrivatePropertyAssignment.ts, 0, 0)) | ||
>foo : Symbol(foo, Decl(typeFromPrivatePropertyAssignment.ts, 0, 12)) | ||
|
||
class C { | ||
>C : Symbol(C, Decl(typeFromPrivatePropertyAssignment.ts, 0, 28)) | ||
|
||
#a?: Foo; | ||
>#a : Symbol(C.#a, Decl(typeFromPrivatePropertyAssignment.ts, 2, 9)) | ||
>Foo : Symbol(Foo, Decl(typeFromPrivatePropertyAssignment.ts, 0, 0)) | ||
|
||
#b?: Foo; | ||
>#b : Symbol(C.#b, Decl(typeFromPrivatePropertyAssignment.ts, 3, 13)) | ||
>Foo : Symbol(Foo, Decl(typeFromPrivatePropertyAssignment.ts, 0, 0)) | ||
|
||
m() { | ||
>m : Symbol(C.m, Decl(typeFromPrivatePropertyAssignment.ts, 4, 13)) | ||
|
||
const a = this.#a || {}; | ||
>a : Symbol(a, Decl(typeFromPrivatePropertyAssignment.ts, 7, 13)) | ||
>this.#a : Symbol(C.#a, Decl(typeFromPrivatePropertyAssignment.ts, 2, 9)) | ||
>this : Symbol(C, Decl(typeFromPrivatePropertyAssignment.ts, 0, 28)) | ||
|
||
this.#b = this.#b || {}; | ||
>this.#b : Symbol(C.#b, Decl(typeFromPrivatePropertyAssignment.ts, 3, 13)) | ||
>this : Symbol(C, Decl(typeFromPrivatePropertyAssignment.ts, 0, 28)) | ||
>this.#b : Symbol(C.#b, Decl(typeFromPrivatePropertyAssignment.ts, 3, 13)) | ||
>this : Symbol(C, Decl(typeFromPrivatePropertyAssignment.ts, 0, 28)) | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/typeFromPrivatePropertyAssignment.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignment.ts === | ||
type Foo = { foo?: string }; | ||
>Foo : Foo | ||
>foo : string | ||
|
||
class C { | ||
>C : C | ||
|
||
#a?: Foo; | ||
>#a : Foo | ||
|
||
#b?: Foo; | ||
>#b : Foo | ||
|
||
m() { | ||
>m : () => void | ||
|
||
const a = this.#a || {}; | ||
>a : Foo | ||
>this.#a || {} : Foo | ||
>this.#a : Foo | ||
>this : this | ||
>{} : {} | ||
|
||
this.#b = this.#b || {}; | ||
>this.#b = this.#b || {} : Foo | ||
>this.#b : Foo | ||
>this : this | ||
>this.#b || {} : Foo | ||
>this.#b : Foo | ||
>this : this | ||
>{} : {} | ||
} | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/typeFromPrivatePropertyAssignmentJs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//// [tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignmentJs.ts] //// | ||
|
||
//// [typeFromPrivatePropertyAssignmentJs.js] | ||
|
||
//// [a.js] | ||
class C { | ||
/** @type {{ foo?: string } | undefined } */ | ||
#a; | ||
/** @type {{ foo?: string } | undefined } */ | ||
#b; | ||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} | ||
|
||
|
||
//// [typeFromPrivatePropertyAssignmentJs.js] | ||
//// [a.js] | ||
class C { | ||
/** @type {{ foo?: string } | undefined } */ | ||
#a; | ||
/** @type {{ foo?: string } | undefined } */ | ||
#b; | ||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/typeFromPrivatePropertyAssignmentJs.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignmentJs.js === | ||
|
||
No type information for this code.=== tests/cases/conformance/classes/members/privateNames/a.js === | ||
class C { | ||
>C : Symbol(C, Decl(a.js, 0, 0)) | ||
|
||
/** @type {{ foo?: string } | undefined } */ | ||
#a; | ||
>#a : Symbol(C.#a, Decl(a.js, 0, 9)) | ||
|
||
/** @type {{ foo?: string } | undefined } */ | ||
#b; | ||
>#b : Symbol(C.#b, Decl(a.js, 2, 7)) | ||
|
||
m() { | ||
>m : Symbol(C.m, Decl(a.js, 4, 7)) | ||
|
||
const a = this.#a || {}; | ||
>a : Symbol(a, Decl(a.js, 6, 13)) | ||
>this.#a : Symbol(C.#a, Decl(a.js, 0, 9)) | ||
>this : Symbol(C, Decl(a.js, 0, 0)) | ||
|
||
this.#b = this.#b || {}; | ||
>this.#b : Symbol(C.#b, Decl(a.js, 2, 7)) | ||
>this : Symbol(C, Decl(a.js, 0, 0)) | ||
>this.#b : Symbol(C.#b, Decl(a.js, 2, 7)) | ||
>this : Symbol(C, Decl(a.js, 0, 0)) | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/typeFromPrivatePropertyAssignmentJs.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignmentJs.js === | ||
|
||
No type information for this code.=== tests/cases/conformance/classes/members/privateNames/a.js === | ||
class C { | ||
>C : C | ||
|
||
/** @type {{ foo?: string } | undefined } */ | ||
#a; | ||
>#a : { foo?: string; } | ||
|
||
/** @type {{ foo?: string } | undefined } */ | ||
#b; | ||
>#b : { foo?: string; } | ||
|
||
m() { | ||
>m : () => void | ||
|
||
const a = this.#a || {}; | ||
>a : { foo?: string; } | ||
>this.#a || {} : { foo?: string; } | ||
>this.#a : { foo?: string; } | ||
>this : this | ||
>{} : {} | ||
|
||
this.#b = this.#b || {}; | ||
>this.#b = this.#b || {} : { foo?: string; } | ||
>this.#b : { foo?: string; } | ||
>this : this | ||
>this.#b || {} : { foo?: string; } | ||
>this.#b : { foo?: string; } | ||
>this : this | ||
>{} : {} | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @target: esnext | ||
|
||
type Foo = { foo?: string }; | ||
|
||
class C { | ||
#a?: Foo; | ||
#b?: Foo; | ||
|
||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/cases/conformance/classes/members/privateNames/typeFromPrivatePropertyAssignmentJs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// @target: esnext | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @outDir: ./out | ||
// @filename: typeFromPrivatePropertyAssignmentJs.js | ||
|
||
// @filename: a.js | ||
class C { | ||
/** @type {{ foo?: string } | undefined } */ | ||
#a; | ||
/** @type {{ foo?: string } | undefined } */ | ||
#b; | ||
m() { | ||
const a = this.#a || {}; | ||
this.#b = this.#b || {}; | ||
} | ||
} |