-
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] Add tests to assert the current typing behavior for the ref pr…
…op in component type Summary: Right now, it will produce good errors during subtyping, but has weird behavior in implicit instantiation. I want to fix it, but let's first assert the current behavior, so we can easily see the improvement later. Changelog: [internal] Reviewed By: panagosg7 Differential Revision: D63154627 fbshipit-source-id: 7f4535592159d1f9a35e79c69eeb2693db6c35a1
- Loading branch information
1 parent
80addb6
commit 7a956a7
Showing
7 changed files
with
499 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[options] | ||
component_syntax=true | ||
all=true | ||
no_flowlib=false |
15 changes: 15 additions & 0 deletions
15
tests/component_type/abstract_component_to_component_type.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,15 @@ | ||
declare const Foo: React.AbstractComponent<{+bar: string}, Instance>; | ||
declare class Instance {} | ||
declare class ImNotARefSetter {} | ||
|
||
Foo as component(bar: string, ref: React.RefSetter<Instance>); // ok | ||
Foo as component(bar: number, ref: React.RefSetter<Instance>); // error: number ~> string | ||
Foo as component(ref: React.RefSetter<Instance>, ...{bar: number}); // error: number ~> string | ||
Foo as component( // error: Instance ~> string | ||
bar: string, | ||
ref: React.RefSetter<string> | ||
); | ||
Foo as component( | ||
bar: string, | ||
ref: ImNotARefSetter // error: bad ref | ||
); |
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,14 @@ | ||
declare class Foo extends React$Component<{bar: string}> {} | ||
declare class ImNotARefSetter {} | ||
|
||
Foo as component(bar: string, ref: React.RefSetter<Foo>); // ok | ||
Foo as component(bar: number, ref: React.RefSetter<Foo>); // error: number ~> string | ||
Foo as component(ref: React.RefSetter<Foo>, ...{bar: number}); // error: number ~> string | ||
Foo as component( // error: Foo ~> string | ||
bar: string, | ||
ref: React.RefSetter<string> | ||
); | ||
Foo as component( | ||
bar: string, | ||
ref: ImNotARefSetter // error: bad ref | ||
); |
Oops, something went wrong.