-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parsing support for
proto
modifier in declare class
Summary: `declare class` creates a nominal instance type. The syntax mirrors the syntax for ES2015 classes, which supports class properties. Class properties are still in the standardization process, but it looks very likely that they will continue to create "own" properties on instances. Upcoming rowk forces us to be more precise about property layout, so I will be making changes to improve our precision about own vs. proto. Class properties are set on the constructed instance as an own property: ``` class A { x = () => "A"; } class B extends A { x() { return "B" } } var b = new B; console.log(b.x()); // "A" (own prop shadows proto) console.log(b.hasOwnProperty("x")); // true console.log(B.prototype.x()); // "B" (proto still exists) ``` Updating Flow to understand the property layout for class hierarchies like this is necessary to be precise about object spread, Object.values, etc. However, in interfaces and declared classes, we occasionally use the class property syntax to declare what are actually prototype properties: ``` declare class Function { bind: Function$Prototype$Apply; // ... } ``` I propose that we add a modifier to indicate that this should be interpreted as a proto property with the given type instead of a class property. ``` declare class Function { proto bind: Function$Prototype$Apply; // ... } ``` Reviewed By: avikchaudhuri Differential Revision: D7824119 fbshipit-source-id: a553d3c891171a72ff0e1941cdeba8ae31d04f58
- Loading branch information
1 parent
649c126
commit eb815be
Showing
99 changed files
with
898 additions
and
38 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"get" | ||
} | ||
|
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 |
---|---|---|
|
@@ -75,6 +75,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"set" | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"get" | ||
} | ||
|
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 |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"set" | ||
} | ||
|
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 |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"get" | ||
} | ||
|
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 |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"set" | ||
} | ||
|
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 |
---|---|---|
|
@@ -73,6 +73,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -77,6 +77,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -182,6 +182,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -182,6 +182,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -101,6 +101,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -74,6 +74,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
"method":true, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
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 |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
"method":false, | ||
"optional":false, | ||
"static":false, | ||
"proto":false, | ||
"variance":null, | ||
"kind":"init" | ||
} | ||
|
Oops, something went wrong.