-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't throw classNameTDZError if referenced identifier is within a Ty…
…peAnnotation (#9190) fix #9189 Obviously this code is intended to throw an error if someone tries to reference a class before it's defined, like: ```js class Foo { someField = Foo; } ``` But there's no problem with referencing the class in a type annotation before it's defined, and this is often necessary for tree structures: ```js class Foo { [someSymbol]: Foo; } ```
- Loading branch information
1 parent
c1499b1
commit 3c8e15d
Showing
7 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...ixtures/plugin-proposal-class-properties/recursive-class-property-type-challenge/input.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,7 @@ | ||
const sym = Symbol(); | ||
const sym1 = Symbol(); | ||
|
||
class A { | ||
[sym]: A.B; | ||
[sym1]: Array<A>; | ||
} |
8 changes: 8 additions & 0 deletions
8
...res/plugin-proposal-class-properties/recursive-class-property-type-challenge/options.json
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,8 @@ | ||
{ | ||
"presets": [ | ||
"flow" | ||
], | ||
"plugins": [ | ||
"proposal-class-properties" | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
...xtures/plugin-proposal-class-properties/recursive-class-property-type-challenge/output.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,13 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
const sym = Symbol(); | ||
const sym1 = Symbol(); | ||
|
||
class A { | ||
constructor() { | ||
_defineProperty(this, sym, void 0); | ||
|
||
_defineProperty(this, sym1, void 0); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...gin/test/fixtures/plugin-proposal-class-properties/recursive-class-property-type/input.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,5 @@ | ||
const sym = Symbol(); | ||
|
||
class A { | ||
[sym]: A; | ||
} |
8 changes: 8 additions & 0 deletions
8
...test/fixtures/plugin-proposal-class-properties/recursive-class-property-type/options.json
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,8 @@ | ||
{ | ||
"presets": [ | ||
"flow" | ||
], | ||
"plugins": [ | ||
"proposal-class-properties" | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...in/test/fixtures/plugin-proposal-class-properties/recursive-class-property-type/output.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,10 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
const sym = Symbol(); | ||
|
||
class A { | ||
constructor() { | ||
_defineProperty(this, sym, void 0); | ||
} | ||
|
||
} |
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