From 62f3020242cbc51884cdccfbdd542f8caa28b61a Mon Sep 17 00:00:00 2001 From: Jenna Smith <175330+jjenzz@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:25:52 +0100 Subject: [PATCH 1/3] fix exported types --- packages/core/src/css/create-themed-component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/css/create-themed-component.tsx b/packages/core/src/css/create-themed-component.tsx index 50544e6..9e32e14 100644 --- a/packages/core/src/css/create-themed-component.tsx +++ b/packages/core/src/css/create-themed-component.tsx @@ -12,7 +12,7 @@ type PropsWithStyledProps = P & StyledProps // prettier-ignore -type Props = C extends ComponentType +export type Props = C extends ComponentType ? MergeProps, PropsWithStyledProps> : never From 1969f02e4904ddc83e96734a35b6d228b33cbe42 Mon Sep 17 00:00:00 2001 From: Jenna Smith <175330+jjenzz@users.noreply.github.com> Date: Thu, 15 Sep 2022 08:55:45 +0100 Subject: [PATCH 2/3] reinstate props generic --- examples/example/App.tsx | 40 +++++++++++++++++++++++++++++++- packages/core/src/css/styled.tsx | 4 +++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/examples/example/App.tsx b/examples/example/App.tsx index 1f57814..a5c5fb6 100644 --- a/examples/example/App.tsx +++ b/examples/example/App.tsx @@ -15,7 +15,12 @@ import { // Import from core import { H4 } from '@dripsy/core' import { Gradient } from '@dripsy/gradient' -import { Text, TextInput, View as NativeView } from 'react-native' +import { + Text, + TextInput, + View as NativeView, + KeyboardAvoidingView, +} from 'react-native' const theme = makeTheme({ colors: { @@ -137,6 +142,39 @@ export type TestElement = MyViewElement extends never ? never : 'ok' // should not have TS errors because element type should not be never ✅ export const testElement: { el: TestElement } = { el: 'ok' } +export const ExtendedComp = styled(KeyboardAvoidingView)({}) + +export const ExtendedCompWithExtraProps = styled< + React.ComponentProps & { custom?: boolean } +>(KeyboardAvoidingView)({}) + +export const ExtendedCompWithExtraProps2 = styled(KeyboardAvoidingView)< + React.ComponentProps & { custom?: boolean } +>({}) + +/* @ts-expect-error behavior cannot be 'test' */ +export const ExtendA = () => +/* should not error */ +export const ExtendB = () => +/* @ts-expect-error custom does not exist */ +export const ExtendC = () => +/* @ts-expect-error behavior cannot be 'test' */ +export const ExtendE = () => +/* should not error */ +export const ExtendF = () => +/* @ts-expect-error custom cannot be string */ +export const ExtendG = () => +/* should not error */ +export const ExtendH = () => +/* @ts-expect-error behavior cannot be 'test' */ +export const ExtendI = () => +/* should not error */ +export const ExtendJ = () => +/* @ts-expect-error custom cannot be string */ +export const ExtendK = () => +/* should not error */ +export const ExtendL = () => + const ResponsiveSquare = () => { // Return literal values: const textColor = useResponsiveValue(['red', 'green', 'blue']) diff --git a/packages/core/src/css/styled.tsx b/packages/core/src/css/styled.tsx index 7dae343..f3dd72c 100644 --- a/packages/core/src/css/styled.tsx +++ b/packages/core/src/css/styled.tsx @@ -16,8 +16,10 @@ import type { ThemedOptions } from './types' * ``` * */ + export function styled< - C extends ComponentType, + Props, + C extends ComponentType = ComponentType, ThemeKey extends keyof DripsyFinalTheme = keyof DripsyFinalTheme >( Component: C, From 2b67ed900eb3d8303b3fd880b7ed18d845152f52 Mon Sep 17 00:00:00 2001 From: Fernando Rojo Date: Thu, 15 Sep 2022 10:22:22 -0400 Subject: [PATCH 3/3] adjust error comments --- examples/example/App.tsx | 44 ++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/examples/example/App.tsx b/examples/example/App.tsx index a5c5fb6..70fd6c9 100644 --- a/examples/example/App.tsx +++ b/examples/example/App.tsx @@ -152,26 +152,48 @@ export const ExtendedCompWithExtraProps2 = styled(KeyboardAvoidingView)< React.ComponentProps & { custom?: boolean } >({}) -/* @ts-expect-error behavior cannot be 'test' */ -export const ExtendA = () => +export const ExtendA = () => ( + +) /* should not error */ export const ExtendB = () => -/* @ts-expect-error custom does not exist */ -export const ExtendC = () => -/* @ts-expect-error behavior cannot be 'test' */ -export const ExtendE = () => +export const ExtendC = () => ( + +) +export const ExtendE = () => ( + +) /* should not error */ export const ExtendF = () => -/* @ts-expect-error custom cannot be string */ -export const ExtendG = () => +export const ExtendG = () => ( + +) /* should not error */ export const ExtendH = () => -/* @ts-expect-error behavior cannot be 'test' */ export const ExtendI = () => + /* should not error */ export const ExtendJ = () => -/* @ts-expect-error custom cannot be string */ -export const ExtendK = () => + +export const ExtendK = () => ( + +) + /* should not error */ export const ExtendL = () =>