You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
I have a use case for withDefaults that doesn't appear to work, but I'm not entirely clear why.
typeProps=|{tag: 'a';href: string;}|{tag: 'button';};declareconstprops: Props;typeDefaultProps={tag: 'a';};declareconstdefaultProps: DefaultProps;declarefunctionwithDefaults<PropsextendsDefaultProps,DefaultPropsextendsobject>(props: Props,defaultProps: DefaultProps,): void;withDefaults(// Type '"button"' is not assignable to type '"a"'.props,defaultProps,);
My thinking:
withDefaults requires DefaultProps (defaultProps) to be a "supertype" of Props (props) (Props extends DefaultProps)
In this example, DefaultProps is not a supertype of Props because Props is a union
Any thoughts?
The text was updated successfully, but these errors were encountered:
Re. https://github.com/gcanti/typelevel-ts/blob/e1d718db887476f7b6b6e2c88542cc6ce3bd8265/examples/withDefaults.tsx
I have a use case for
withDefaults
that doesn't appear to work, but I'm not entirely clear why.My thinking:
withDefaults
requiresDefaultProps
(defaultProps
) to be a "supertype" ofProps
(props
) (Props extends DefaultProps
)DefaultProps
is not a supertype ofProps
becauseProps
is a unionAny thoughts?
The text was updated successfully, but these errors were encountered: