-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse error on private identifier optional chain (#35987)
Previously, this error was reported in the checker, so JS files with checkJs: false were not erroring on this invalid syntax.
- Loading branch information
1 parent
9fbcdb1
commit f84b2d2
Showing
8 changed files
with
74 additions
and
8 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
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
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
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
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/privateNameUncheckedJsOptionalChain.errors.txt
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 @@ | ||
tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.js(4,15): error TS18030: An optional chain cannot contain private identifiers. | ||
tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.js(5,15): error TS18030: An optional chain cannot contain private identifiers. | ||
|
||
|
||
==== tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.js (2 errors) ==== | ||
class C { | ||
#bar; | ||
constructor () { | ||
this?.#foo; | ||
~~~~ | ||
!!! error TS18030: An optional chain cannot contain private identifiers. | ||
this?.#bar; | ||
~~~~ | ||
!!! error TS18030: An optional chain cannot contain private identifiers. | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/privateNameUncheckedJsOptionalChain.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,17 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.js === | ||
class C { | ||
>C : Symbol(C, Decl(privateNameUncheckedJsOptionalChain.js, 0, 0)) | ||
|
||
#bar; | ||
>#bar : Symbol(C.#bar, Decl(privateNameUncheckedJsOptionalChain.js, 0, 9)) | ||
|
||
constructor () { | ||
this?.#foo; | ||
>this : Symbol(C, Decl(privateNameUncheckedJsOptionalChain.js, 0, 0)) | ||
|
||
this?.#bar; | ||
>this?.#bar : Symbol(C.#bar, Decl(privateNameUncheckedJsOptionalChain.js, 0, 9)) | ||
>this : Symbol(C, Decl(privateNameUncheckedJsOptionalChain.js, 0, 0)) | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/privateNameUncheckedJsOptionalChain.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,18 @@ | ||
=== tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.js === | ||
class C { | ||
>C : C | ||
|
||
#bar; | ||
>#bar : any | ||
|
||
constructor () { | ||
this?.#foo; | ||
>this?.#foo : any | ||
>this : this | ||
|
||
this?.#bar; | ||
>this?.#bar : any | ||
>this : this | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
tests/cases/conformance/classes/members/privateNames/privateNameUncheckedJsOptionalChain.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 @@ | ||
// @allowJs: true | ||
// @checkJs: false | ||
// @noEmit: true | ||
// @Filename: privateNameUncheckedJsOptionalChain.js | ||
// @target: es2015 | ||
|
||
class C { | ||
#bar; | ||
constructor () { | ||
this?.#foo; | ||
this?.#bar; | ||
} | ||
} |