-
Notifications
You must be signed in to change notification settings - Fork 82
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
fix exported types #239
fix exported types #239
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hmm but this still doesn't allow the |
oh, i didn't realise that was an intended api 😬 my bad. what is the expectation if someone does |
i'll have to take a look another time as it is super late here now, sorry. unfortunately, the // would infer correctly
const a = styled(Text)()
// inference would break because `C` would fallback to its default value (likely `ComponentType<any>`)
const b = styled<{ prop?: boolean }>(Text)(); my solution relies on being able to infer the the best solution for now might be to revert my change. or would you consider deprecating the broken api? |
@nandorojo funny what a bit of sleep can do. this should all be working now assuming the following tests look okay to you? note that when using export const ExtendedCompWithExtraProps = styled<
React.ComponentProps<typeof KeyboardAvoidingView> & { custom?: boolean }
>(KeyboardAvoidingView)({})
/* @ts-expect-error behavior cannot be 'test' */
export const ExtendE = () => <ExtendedCompWithExtraProps behavior="test" />
/* should not error */
export const ExtendF = () => <ExtendedCompWithExtraProps behavior="padding" />
/* @ts-expect-error custom cannot be string */
export const ExtendG = () => <ExtendedCompWithExtraProps custom="test" />
/* should not error */
export const ExtendH = () => <ExtendedCompWithExtraProps custom={false} /> |
examples/example/App.tsx
Outdated
export const ExtendedComp = styled(KeyboardAvoidingView)({}) | ||
|
||
export const ExtendedCompWithExtraProps = styled< | ||
React.ComponentProps<typeof KeyboardAvoidingView> & { custom?: boolean } | ||
>(KeyboardAvoidingView)({}) | ||
|
||
export const ExtendedCompWithExtraProps2 = styled(KeyboardAvoidingView)< | ||
React.ComponentProps<typeof KeyboardAvoidingView> & { custom?: boolean } | ||
>({}) | ||
|
||
/* @ts-expect-error behavior cannot be 'test' */ | ||
export const ExtendA = () => <ExtendedComp behavior="test" /> | ||
/* should not error */ | ||
export const ExtendB = () => <ExtendedComp behavior="padding" /> | ||
/* @ts-expect-error custom does not exist */ | ||
export const ExtendC = () => <ExtendedComp custom="test" /> | ||
/* @ts-expect-error behavior cannot be 'test' */ | ||
export const ExtendE = () => <ExtendedCompWithExtraProps behavior="test" /> | ||
/* should not error */ | ||
export const ExtendF = () => <ExtendedCompWithExtraProps behavior="padding" /> | ||
/* @ts-expect-error custom cannot be string */ | ||
export const ExtendG = () => <ExtendedCompWithExtraProps custom="test" /> | ||
/* should not error */ | ||
export const ExtendH = () => <ExtendedCompWithExtraProps custom={false} /> | ||
/* @ts-expect-error behavior cannot be 'test' */ | ||
export const ExtendI = () => <ExtendedCompWithExtraProps2 behavior="test" /> | ||
/* should not error */ | ||
export const ExtendJ = () => <ExtendedCompWithExtraProps2 behavior="padding" /> | ||
/* @ts-expect-error custom cannot be string */ | ||
export const ExtendK = () => <ExtendedCompWithExtraProps2 custom="test" /> | ||
/* should not error */ | ||
export const ExtendL = () => <ExtendedCompWithExtraProps2 custom={false} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like all this type testing should belong somewhere else other than examples/example/App.tsx
... some kind of tests.tsx
file somewhere. let me know if you'd like me to move it all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this should get cleaned up at some point. examples
isn't a great name for this, it's really just for local dev testing. i point people to the solito starter instead for using dripsy
this behavior looks right! i'll take a look today |
@nandorojo great, thanks ❤️ also, just a heads up that for some reason installing older versions of dripsy installs the latest versions of types so my project has errors everywhere that i cannot silence with a downgrade 🙈 not sure why older versions don't pull types specific to that version but something for you to look into separately perhaps? |
hmm it could be something related to the monorepo setup perhaps...not sure. hopefully publishing the newer version will fix it all |
if you also have gradient installed, be sure to fix it at the same version. i'm going to fix this in v4 |
@nandorojo i think it may have been something to do with local caching (pnpm maybe 🤷 ). i've completely removed a bunch of stuff and reinstalled |
just published an updated version ( |
Hey @jjenzz! I think one of these PRs caused a type regression for Here's the issue: #260 Thank you (& happy holidays!) |
Fixes issue mentioned here #237 (comment)
The
styled.d.ts
definition was trying to manually construct theProps
type and looks like it was getting it wrong somewhere. Exporting the type will ensure it usesimport("./create-themed-component").Props
correctly instead.DIFF