-
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] Ban unsafe string index access in indexed access types
Summary: Thanks to George's work that records whether GetPropT comes from annotation, we can limit the ban to annotation only. We should still ban it completely at some point. However, unlike in runtime code, this kind of pattern has no hope of codemodding it into anything correct, so we will start from here. Changelog: [errors] Invalid indexed access types with string index, like `{foo: string}[string]` will now error instead of silently making it any. Reviewed By: panagosg7 Differential Revision: D55457589 fbshipit-source-id: 2945809f279c46c5f23e747d56ad6d93034d4972
- Loading branch information
1 parent
bbe7df6
commit fe00f4c
Showing
10 changed files
with
170 additions
and
56 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
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 @@ | ||
import type { Bad, Obj2 } from "./exported_bad_evalt"; | ||
|
||
declare const bad: Bad; | ||
bad.get() as Obj2; // error: TODO should not error here, since annotation error should be non-speculative | ||
bad.get(1) as Obj2; // error: TODO spurious incompatible with empty |
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 @@ | ||
declare export class C<T> { | ||
get(): T | null; | ||
get(v: T): T; | ||
} | ||
type Obj = {foo: string}; | ||
export type Obj2 = {...Obj} | ||
|
||
export type Bad = C<Obj2[string]>; |
Oops, something went wrong.