Skip to content

Commit

Permalink
[flow][render-types] Make Context Providers transparent
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: SamChou19815

Differential Revision: D68355260

fbshipit-source-id: e451d96fa0aada1ec6f39b9db2c2fd5e285dc31c
  • Loading branch information
jbrown215 authored and facebook-github-bot committed Jan 22, 2025
1 parent 334e26c commit 6b8a101
Show file tree
Hide file tree
Showing 16 changed files with 313 additions and 319 deletions.
14 changes: 4 additions & 10 deletions lib/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,10 @@ declare type React$RefSetter<-T> =
* The type of a React Context. React Contexts are created by calling
* createContext() with a default value.
*/
declare opaque type React$Context<T>: React$ComponentType<{
+value: T,
+children?: React$Node,
...
}> & {
Provider: React$ComponentType<{
+value: T,
+children?: React$Node,
...
}>,
declare opaque type React$Context<T>:
component<Renders: React$Node = React$Node>(value: T, children?: Renders, ...{...}) renders Renders
& {
Provider: component<Renders: React$Node = React$Node>(value: T, children?: Renders, ...{...}) renders Renders,
Consumer: React$ComponentType<{ +children: (value: T) => ?React$Node, ... }>,
// Optional, user-specified value for custom display label in React DevTools.
displayName?: string,
Expand Down
4 changes: 2 additions & 2 deletions tests/badly_positioned_react/badly_positioned_react.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ References:
test.js:21:29
21| const Foo1 = create(create1<{||}>(Foo));
^^^^ [2]
<BUILTINS>/react.js:351:38
351| declare export type ComponentType<-P> = React$ComponentType<P>;
<BUILTINS>/react.js:345:38
345| declare export type ComponentType<-P> = React$ComponentType<P>;
^ [3]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Cannot cast `3` to indexed access because number [1] is incompatible with compon
^ [1]

References:
<BUILTINS>/react.js:750:5
<BUILTINS>/react.js:744:5
v------------------------------------------------------
750| declare component Fragment<Renders: React$Node = void>(
751| children?: Renders,
752| ) renders Renders;
744| declare component Fragment<Renders: React$Node = void>(
745| children?: Renders,
746| ) renders Renders;
-----------------^ [2]


Expand Down
16 changes: 8 additions & 8 deletions tests/component_type/component_type.exp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ References:
component_to_component.js:26:37
26| x: component(ref: React.RefSetter<Component>, ...{...}),
^^^^^^^^^ [2]
<BUILTINS>/react.js:367:34
367| declare export type RefSetter<-T> = React$RefSetter<T>;
<BUILTINS>/react.js:361:34
361| declare export type RefSetter<-T> = React$RefSetter<T>;
^ [3]


Expand Down Expand Up @@ -426,8 +426,8 @@ Cannot create `C` element because in property `ref`: [incompatible-type]
^^^^^^

References:
<BUILTINS>/react.js:700:8
700| ): React$RefObject<T | null>;
<BUILTINS>/react.js:694:8
694| ): React$RefObject<T | null>;
^^^^^^^^^^^^^^^^^^^^^^^^^ [1]
<BUILTINS>/react.js:197:6
197| | ((T | null) => mixed)
Expand Down Expand Up @@ -575,8 +575,8 @@ References:
<BUILTINS>/core.js:2060:19
2060| declare class Set<T> extends $ReadOnlySet<T> {
^ [3]
<BUILTINS>/react.js:237:19
237| type RefSetter<-T> = React$RefSetter<T>;
<BUILTINS>/react.js:231:19
231| type RefSetter<-T> = React$RefSetter<T>;
^ [4]


Expand Down Expand Up @@ -991,8 +991,8 @@ References:
<BUILTINS>/core.js:2060:19
2060| declare class Set<T> extends $ReadOnlySet<T> {
^ [3]
<BUILTINS>/react.js:237:19
237| type RefSetter<-T> = React$RefSetter<T>;
<BUILTINS>/react.js:231:19
231| type RefSetter<-T> = React$RefSetter<T>;
^ [4]


Expand Down
4 changes: 2 additions & 2 deletions tests/new_generics/new_generics.exp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,8 @@ References:
react.js:13:28
13| a as React.ComponentType<{a: number}>; // nope, contravariance
^^^^^^^^^^^ [2]
<BUILTINS>/react.js:351:38
351| declare export type ComponentType<-P> = React$ComponentType<P>;
<BUILTINS>/react.js:345:38
345| declare export type ComponentType<-P> = React$ComponentType<P>;
^ [3]


Expand Down
Loading

0 comments on commit 6b8a101

Please sign in to comment.