-
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.
[flow][numeric-keys] Add support for int-like property keys (#7593)
Summary: Our previous handling of numeric property keys is very unsafe. We add support for treating int-like numbers (less than the max safe integer) as property keys. We treat these numbers as they are treated at runtime - we convert them to strings. See post for more. Also see previous diff, as it adds some of the utilities used here. Fixes #380 (#380 from 2015!) Closes #7593 Changelog: [errors] You can now create and access object keys with int-like number literals, these act as their string equivalents. Reviewed By: SamChou19815 Differential Revision: D51567388 fbshipit-source-id: de8f4ba906aaee0a4b881b087aedbf45d9c1c365
- Loading branch information
1 parent
3032229
commit 80ca16f
Showing
21 changed files
with
740 additions
and
399 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
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 @@ | ||
{ | ||
declare const x: [string]; | ||
const [a] = x; | ||
(a: string); // OK | ||
(a: empty); // ERROR | ||
} | ||
|
||
// Non-arrays/tuples | ||
{ | ||
declare const o: {foo: 1}; | ||
const [x] = o; // ERROR | ||
} | ||
|
||
{ | ||
declare const f: number => boolean; | ||
const [x] = f; // ERROR | ||
} |
Oops, something went wrong.