Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript 4.4 exactOptionalPropertyTypes #1919

Open
aaronadamsCA opened this issue Sep 3, 2021 · 0 comments
Open

Support TypeScript 4.4 exactOptionalPropertyTypes #1919

aaronadamsCA opened this issue Sep 3, 2021 · 0 comments
Labels
bug Something isn't working types

Comments

@aaronadamsCA
Copy link
Contributor

aaronadamsCA commented Sep 3, 2021

Is your feature request related to a problem? Please describe.
Typescript 4.4 introduced a new feature, exactOptionalPropertyTypes. The default value is false but the recommended value is true.

Describe the solution you'd like
Theme UI needs some type improvements to work correctly with this setting enabled.

Additional context
Here is an example of an error that occurs only when this setting is enabled:

import type { BoxProps } from "@theme-ui/components";
import { Box } from "@theme-ui/components";

export const Example = (props: BoxProps): JSX.Element => <Box {...props} />;

The error appears on Box:

Type '{ slot?: string | undefined; style?: CSSProperties | undefined; title?: string | undefined; key?: Key | null | undefined; defaultChecked?: boolean | undefined; ... 285 more ...; opacity?: ResponsiveValue<...> | undefined; }' is not assignable to type 'BoxOwnProps'.
  Types of property 'color' are incompatible.
    Type 'string | undefined' is not assignable to type 'ResponsiveValue<never, Required<Theme<TLengthStyledSystem>>> | undefined'.
      Type 'string' is not assignable to type 'ResponsiveValue<never, Required<Theme<TLengthStyledSystem>>> | undefined'. ts(2322)

I believe the issue may be upstream in @types/styled-system, but I don't understand how to diagnose it well enough to report it. I'm hoping somebody with more TypeScript knowledge could figure out how to get this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types
Projects
None yet
Development

No branches or pull requests

2 participants