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

Fixes for --exactOptionalPropertyTypes TS flag #827

Merged
merged 1 commit into from Aug 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/react/src/styled.ts
Expand Up @@ -63,13 +63,15 @@ interface IProps {
// If styled wraps custom component, that component should have className property
function styled<TConstructor extends React.FunctionComponent<any>>(
tag: TConstructor extends React.FunctionComponent<infer T>
? T extends { className?: string }
? T extends { className?: string | undefined }
? TConstructor
: never
: never
): ComponentStyledTag<TConstructor>;
function styled<T>(
tag: T extends { className?: string } ? React.ComponentType<T> : never
tag: T extends { className?: string | undefined }
? React.ComponentType<T>
: never
): ComponentStyledTag<T>;
function styled<TName extends keyof JSX.IntrinsicElements>(
tag: TName
Expand Down Expand Up @@ -197,7 +199,7 @@ type ComponentStyledTag<T> = <
>(
strings: TemplateStringsArray,
// Expressions can contain functions only if wrapped component has style property
...exprs: TrgProps extends { style?: React.CSSProperties }
...exprs: TrgProps extends { style?: React.CSSProperties | undefined }
? Array<
| StaticPlaceholder
| ((props: NoInfer<OwnProps & TrgProps>) => string | number)
Expand Down