Skip to content

Commit

Permalink
[flow] Kill React.Config
Browse files Browse the repository at this point in the history
Summary: Changelog: [errors] `React.Config` type, deprecated in v0.254, is now removed.

Reviewed By: jbrown215

Differential Revision: D66886469

fbshipit-source-id: de1e575e63c8626e6f6decd89dd6b5fb7a8e8f20
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Dec 6, 2024
1 parent d970fb6 commit 3ed06b5
Show file tree
Hide file tree
Showing 40 changed files with 324 additions and 490 deletions.
23 changes: 0 additions & 23 deletions lib/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ declare namespace React {
type ElementProps<C> = React$ElementProps<C>;
type ElementConfig<C> = React$ElementConfig<C>;
type ElementRef<C> = React$ElementRef<C>;
type Config<Props, DefaultProps> = React$Config<Props, DefaultProps>;

type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
type ReactSetStateFunction<S> = ((S => S) | S) => void;
Expand Down Expand Up @@ -386,17 +385,6 @@ declare module react {
declare export type ElementProps<C> = React$ElementProps<C>;
declare export type ElementConfig<C> = React$ElementConfig<C>;
declare export type ElementRef<C> = React$ElementRef<C>;
/**
* @deprecated This type is only useful for legacy class components. You can create your
* own equivalent type with
*
* ```js
* type ReactConfigShim<Props, DefaultProps> = $ReadOnly<{
* ...Omit<Props, $Keys<DefaultProps>>, ...Partial<DefaultProps>
* }>;
* ```
*/
declare export type Config<Props, DefaultProps> = React$Config<Props, DefaultProps>;

declare interface Thenable<T> {
then(
Expand Down Expand Up @@ -1040,17 +1028,6 @@ declare module react {
type ElementProps<C> = React$ElementProps<C>;
type ElementConfig<C> = React$ElementConfig<C>;
type ElementRef<C> = React$ElementRef<C>;
/**
* @deprecated This type is only useful for legacy class components. You can create your
* own equivalent type with
*
* ```js
* type ReactConfigShim<Props, DefaultProps> = $ReadOnly<{
* ...Omit<Props, $Keys<DefaultProps>>, ...Partial<DefaultProps>
* }>;
* ```
*/
type Config<Props, DefaultProps> = React$Config<Props, DefaultProps>;

type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
type ReactSetStateFunction<S> = ((S => S) | S) => void;
Expand Down
2 changes: 0 additions & 2 deletions src/common/errors/error_codes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ type error_code =
| InvalidModule
| InvalidPropertyTypeArg
| InvalidPropType
| InvalidReactConfig
| InvalidReactCreateElement
| InvalidRendersTypeArgument
| InvalidSupportsPlatformDecl
Expand Down Expand Up @@ -309,7 +308,6 @@ let string_of_code : error_code -> string = function
| InvalidModule -> "invalid-module"
| InvalidPropertyTypeArg -> "invalid-property-type-arg"
| InvalidPropType -> "invalid-prop-type"
| InvalidReactConfig -> "invalid-react-config"
| InvalidReactCreateElement -> "invalid-react-create-element"
| InvalidRendersTypeArgument -> "invalid-render"
| InvalidSupportsPlatformDecl -> "invalid-supports-platform"
Expand Down
6 changes: 1 addition & 5 deletions src/common/reason.ml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ type 'loc virtual_reason_desc =
| RReactChildrenOrType of 'loc virtual_reason_desc
| RReactChildrenOrUndefinedOrType of 'loc virtual_reason_desc
| RReactRef
| RReactConfig
| RPossiblyMissingPropFromObj of name * 'loc virtual_reason_desc
| RUnionBranching of 'loc virtual_reason_desc * int
| RUninitialized
Expand Down Expand Up @@ -313,8 +312,7 @@ let rec map_desc_locs f = function
| RMatchingProp (s, desc) -> RMatchingProp (s, map_desc_locs f desc)
| RImplicitThis desc -> RImplicitThis (map_desc_locs f desc)
| ( RObjectPatternRestProp | RArrayPatternRestProp | RModule _ | RNamespace _ | ROptionalChain
| RReactProps | RReactElement _ | RReactDefaultProps | RReactChildren | RReactRef | RReactConfig
) as r ->
| RReactProps | RReactElement _ | RReactDefaultProps | RReactChildren | RReactRef ) as r ->
r
| RReactChildrenOrType desc -> RReactChildrenOrType (map_desc_locs f desc)
| RReactChildrenOrUndefinedOrType desc -> RReactChildrenOrUndefinedOrType (map_desc_locs f desc)
Expand Down Expand Up @@ -719,7 +717,6 @@ let rec string_of_desc = function
| RReactChildrenOrType desc -> spf "children array or %s" (string_of_desc desc)
| RReactChildrenOrUndefinedOrType desc -> spf "children array or %s" (string_of_desc desc)
| RReactRef -> "React component ref"
| RReactConfig -> "config of React component"
| RPossiblyMissingPropFromObj (propname, desc) ->
spf
"possibly missing property `%s` in %s"
Expand Down Expand Up @@ -1441,7 +1438,6 @@ let classification_of_reason_desc desc =
| RReactChildrenOrType _
| RReactChildrenOrUndefinedOrType _
| RReactRef
| RReactConfig
| RPossiblyMissingPropFromObj _
| RUnionBranching _
| REnum _
Expand Down
1 change: 0 additions & 1 deletion src/common/reason.mli
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ type 'loc virtual_reason_desc =
| RReactChildrenOrType of 'loc virtual_reason_desc
| RReactChildrenOrUndefinedOrType of 'loc virtual_reason_desc
| RReactRef
| RReactConfig
| RPossiblyMissingPropFromObj of name * 'loc virtual_reason_desc
| RUnionBranching of 'loc virtual_reason_desc * int
| RUninitialized
Expand Down
4 changes: 0 additions & 4 deletions src/common/ty/ty.ml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ and utility =
(* React utils *)
| ReactElementPropsType of t
| ReactElementConfigType of t
| ReactConfigType of t * t

and component_props =
| UnflattenedComponentProps of t
Expand Down Expand Up @@ -697,7 +696,6 @@ class ['A] comparator_ty =
| Class _ -> 13
| ReactElementPropsType _ -> 18
| ReactElementConfigType _ -> 19
| ReactConfigType _ -> 21
| ObjKeyMirror _ -> 22
| Partial _ -> 23
| Required _ -> 24
Expand Down Expand Up @@ -867,7 +865,6 @@ let string_of_utility_ctor = function
| StringSuffix _ -> "StringSuffix"
| ReactElementPropsType _ -> "React$ElementProps"
| ReactElementConfigType _ -> "React$ElementConfig"
| ReactConfigType _ -> "React$Config"

let types_of_utility = function
| Keys t -> Some [t]
Expand All @@ -892,7 +889,6 @@ let types_of_utility = function
Some [StrLit (Reason.OrdinaryName arg); t]
| ReactElementPropsType t -> Some [t]
| ReactElementConfigType t -> Some [t]
| ReactConfigType (t1, t2) -> Some [t1; t2]

let string_of_prop_source = function
| Interface -> "interface"
Expand Down
5 changes: 0 additions & 5 deletions src/parser_utils/type_sig/type_sig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,6 @@ type ('loc, 'a) annot =
loc: 'loc;
config: 'a;
}
| ReactConfig of {
loc: 'loc;
props: 'a;
default: 'a;
}
| ReactCreateClass of 'loc
| ReactElementProps of 'loc * 'a
| ReactElementConfig of 'loc * 'a
Expand Down
8 changes: 0 additions & 8 deletions src/parser_utils/type_sig/type_sig_parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2406,14 +2406,6 @@ and maybe_special_unqualified_generic opts scope tbls xs loc targs ref_loc =
| _ -> Err (loc, CheckError))
| _ -> Err (loc, CheckError)
end
| "React$Config" -> begin
match targs with
| Some (_, { arguments = [props; default]; _ }) ->
let props = annot opts scope tbls xs props in
let default = annot opts scope tbls xs default in
Annot (ReactConfig { loc; props; default })
| _ -> Err (loc, CheckError)
end
| "React$ElementProps" -> begin
match targs with
| Some (_, { arguments = [t]; _ }) ->
Expand Down
8 changes: 0 additions & 8 deletions src/typing/debug_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ let string_of_destructor = function
| TypeMap ObjectKeyMirror -> "ObjectKeyMirror"
| ReactElementPropsType -> "ReactElementProps"
| ReactElementConfigType -> "ReactElementConfig"
| ReactConfigType _ -> "ReactConfig"
| MappedType _ -> "MappedType"

let string_of_destruct_kind = function
Expand Down Expand Up @@ -452,8 +451,6 @@ and dump_use_t_ (depth, tvars) cx t =
| ConfigCheck { props; instance = _ } -> spf "ConfigCheck (%s)" (kid props)
| GetProps tout -> spf "GetProps (%s)" (kid tout)
| GetConfig tout -> spf "GetConfig (%s)" (kid tout)
| GetConfigType (default_props, tout) ->
spf "GetConfigType (%s, %s)" (kid default_props) (kid tout)
| GetRef tout -> spf "GetRef (%s)" (kid tout)
)
in
Expand Down Expand Up @@ -1573,11 +1570,6 @@ let dump_error_message =
"ENotAReactComponent { reason = %s; use_op = %s }"
(dump_reason cx reason)
(string_of_use_op use_op)
| EInvalidReactConfigType { reason; use_op } ->
spf
"EInvalidReactConfigType { reason = %s; use_op = %s }"
(dump_reason cx reason)
(string_of_use_op use_op)
| EReactElementFunArity (reason, _, _) ->
spf "EReactElementFunArity (%s)" (dump_reason cx reason)
| EFunctionCallExtraArg (unused_reason, def_reason, param_count, use_op) ->
Expand Down
1 change: 0 additions & 1 deletion src/typing/default_resolve.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ let rec default_resolve_touts ~flow ?resolve_callee cx loc u =
| ConfigCheck { props = tout; instance = _ }
| GetProps tout
| GetConfig tout
| GetConfigType (_, tout)
| GetRef tout ->
resolve tout
in
Expand Down
18 changes: 0 additions & 18 deletions src/typing/errors/error_message.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ and 'loc t' =
reason: 'loc virtual_reason;
use_op: 'loc virtual_use_op;
}
| EInvalidReactConfigType of {
reason: 'loc virtual_reason;
use_op: 'loc virtual_use_op;
}
| EInvalidReactCreateElement of {
create_element_loc: 'loc;
invalid_react: 'loc virtual_reason;
Expand Down Expand Up @@ -991,8 +987,6 @@ let rec map_loc_of_error_message (f : 'a -> 'b) : 'a t' -> 'b t' =
}
| ENotAReactComponent { reason; use_op } ->
ENotAReactComponent { reason = map_reason reason; use_op = map_use_op use_op }
| EInvalidReactConfigType { reason; use_op } ->
EInvalidReactConfigType { reason = map_reason reason; use_op = map_use_op use_op }
| EInvalidReactCreateElement { create_element_loc; invalid_react } ->
EInvalidReactCreateElement
{ create_element_loc = f create_element_loc; invalid_react = map_reason invalid_react }
Expand Down Expand Up @@ -1519,8 +1513,6 @@ let util_use_op_of_msg nope util = function
util use_op (fun use_op -> EEnumIncompatible { contents with use_op })
| ENotAReactComponent { reason; use_op } ->
util use_op (fun use_op -> ENotAReactComponent { reason; use_op })
| EInvalidReactConfigType { reason; use_op } ->
util use_op (fun use_op -> EInvalidReactConfigType { reason; use_op })
| EFunctionCallExtraArg (rl, ru, n, op) ->
util op (fun op -> EFunctionCallExtraArg (rl, ru, n, op))
| EPrimitiveAsInterface { use_op; reason; interface_reason; kind } ->
Expand Down Expand Up @@ -1918,7 +1910,6 @@ let loc_of_msg : 'loc t' -> 'loc option = function
| EInexactMayOverwriteIndexer _
| EFunctionCallExtraArg _
| ENotAReactComponent _
| EInvalidReactConfigType _
| EIncompatibleWithUseOp _
| EEnumIncompatible _
| EIncompatibleDefs _
Expand Down Expand Up @@ -2543,14 +2534,6 @@ let friendly_message_of_msg = function
use_op;
explanation = None;
}
| EInvalidReactConfigType { reason; use_op } ->
UseOp
{
loc = loc_of_reason reason;
message = MessageCannotCalculateReactConfig reason;
use_op;
explanation = None;
}
| EReactElementFunArity (_, fn_name, n) ->
Normal (MessageCannotCallReactFunctionWithoutAtLeastNArgs { fn_name; n })
| EReactRefInRender { usage; kind = Argument; in_hook } ->
Expand Down Expand Up @@ -3061,7 +3044,6 @@ let error_code_of_message err : error_code option =
| EInvalidLHSInAssignment _ -> Some InvalidLhs
| EInvalidObjectKit _ -> Some NotAnObject
| EInvalidPrototype _ -> Some NotAnObject
| EInvalidReactConfigType _ -> Some InvalidReactConfig
| EInvalidReactCreateElement _ -> Some InvalidReactCreateElement
| EInvalidTypeArgs (_, _) -> Some InvalidTypeArg
| EInvalidTypeof _ -> Some IllegalTypeof
Expand Down
1 change: 0 additions & 1 deletion src/typing/errors/flow_intermediate_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,6 @@ let to_printable_error :
text "Cannot build a typed interface for this module. "
:: text "You should annotate the exports of this module with types. "
:: features
| MessageCannotCalculateReactConfig reason -> [ref reason; text " cannot calculate config"]
| MessageCannotCallMaybeReactHook { callee_loc; hooks; non_hooks } ->
let hook_blame =
match hooks with
Expand Down
1 change: 0 additions & 1 deletion src/typing/errors/flow_intermediate_error_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ type 'loc message =
}
| MessageCannotAssignToInvalidLHS
| MessageCannotBuildTypedInterface of 'loc Signature_error.t
| MessageCannotCalculateReactConfig of 'loc virtual_reason
| MessageCannotCallMaybeReactHook of {
callee_loc: 'loc;
hooks: 'loc list;
Expand Down
5 changes: 0 additions & 5 deletions src/typing/flow_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6827,11 +6827,6 @@ struct
rec_flow cx trace (t, ReactKitT (use_op, reason, React.GetProps (OpenT tout)))
| ReactElementConfigType ->
rec_flow cx trace (t, ReactKitT (use_op, reason, React.GetConfig (OpenT tout)))
| ReactConfigType default_props ->
rec_flow
cx
trace
(t, ReactKitT (use_op, reason, React.GetConfigType (default_props, OpenT tout)))
| MappedType { property_type; mapped_type_flags; homomorphic; distributive_tparam_name } ->
let (property_type, homomorphic) =
substitute_mapped_type_distributive_tparams
Expand Down
3 changes: 1 addition & 2 deletions src/typing/implicit_instantiation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ module Make (Observer : OBSERVER) (Flow : Flow_common.S) : S = struct
| ReactDRO _
| MakeHooklike
| PartialType
| RequiredType
| ReactConfigType _ ->
| RequiredType ->
merge_lower_or_upper_bounds r (OpenT tout)
| ReactCheckComponentConfig pmap ->
merge_lower_or_upper_bounds r (OpenT tout)
Expand Down
23 changes: 0 additions & 23 deletions src/typing/react_kit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module Kit (Flow : Flow_common.S) : REACT = struct
| CreateElement _
| ConfigCheck _ ->
Error_message.ENotAReactComponent { reason; use_op }
| GetConfigType _ -> Error_message.EInvalidReactConfigType { reason; use_op }
in
Flow_js_utils.add_output cx err

Expand Down Expand Up @@ -858,27 +857,6 @@ module Kit (Flow : Flow_common.S) : REACT = struct
rec_flow_t ~use_op:unknown_use cx trace (elem, tout)
in
let get_config = get_config cx trace l ~use_op ~reason_op u Polarity.Positive in
let get_config_with_props_and_defaults default_props tout =
Object.(
Object.Rest.(
let props = l in
let tool = Resolve Next in
let state = One default_props in
rec_flow
cx
trace
( props,
ObjKitT
( Op UnknownUse,
reason_op,
tool,
Rest (ReactConfigMerge Polarity.Neutral, state),
tout
)
)
)
)
in
let get_instance tout =
let component = l in
match drop_generic component with
Expand Down Expand Up @@ -940,6 +918,5 @@ module Kit (Flow : Flow_common.S) : REACT = struct
| ConfigCheck { props = jsx_props; instance } -> config_check use_op ~instance ~jsx_props
| GetProps tout -> props_to_tout tout
| GetConfig tout -> get_config tout
| GetConfigType (default_props, tout) -> get_config_with_props_and_defaults default_props tout
| GetRef tout -> get_instance tout
end
7 changes: 1 addition & 6 deletions src/typing/ty_normalizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ module Make (I : INPUT) : S = struct
| TypeMap _
| ReactElementPropsType
| ReactElementConfigType
| ReactConfigType _
| ReactCheckComponentConfig _
| ReactDRO _
| MakeHooklike
Expand Down Expand Up @@ -485,8 +484,7 @@ module Make (I : INPUT) : S = struct
| TypeMap _
| EnumType
| ReactElementPropsType
| ReactElementConfigType
| ReactConfigType _ ->
| ReactElementConfigType ->
false)
)
| Env.EvaluateAll ->
Expand Down Expand Up @@ -1756,9 +1754,6 @@ module Make (I : INPUT) : S = struct
| T.ReactCheckComponentConfig pmap -> check_component ~env ty pmap
| T.ReactElementPropsType -> return (Ty.Utility (Ty.ReactElementPropsType ty))
| T.ReactElementConfigType -> return (Ty.Utility (Ty.ReactElementConfigType ty))
| T.ReactConfigType default_props ->
let%map default_props' = type__ ~env default_props in
Ty.Utility (Ty.ReactConfigType (ty, default_props'))
| T.RestType ((T.Object.Rest.SpreadReversal | T.Object.Rest.ReactConfigMerge _), _) as d ->
terr ~kind:BadEvalT ~msg:(Debug_js.string_of_destructor d) None
| T.MappedType { property_type; mapped_type_flags; homomorphic; distributive_tparam_name } ->
Expand Down
2 changes: 0 additions & 2 deletions src/typing/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,6 @@ module rec TypeTerm : sig
| TypeMap of type_map
| ReactElementPropsType
| ReactElementConfigType
| ReactConfigType of t
| ReactCheckComponentConfig of Property.t NameUtils.Map.t
| ReactDRO of react_dro
| MakeHooklike
Expand Down Expand Up @@ -3058,7 +3057,6 @@ and React : sig
}
| GetProps of TypeTerm.t_out
| GetConfig of TypeTerm.t_out
| GetConfigType of TypeTerm.t * TypeTerm.t_out
| GetRef of TypeTerm.t_out
end =
React
Expand Down
Loading

0 comments on commit 3ed06b5

Please sign in to comment.