-
Notifications
You must be signed in to change notification settings - Fork 5
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
Once built, polymorphed types become generic "string" types #10
Comments
I haven't really used this package to make another package, but I don't see how that should break things. I guess you could try to check what import { TypographyProps } from "your-package";
import { PolyForwardComponent } from "react-polymorphed";
// test A
declare const props: TypographyProps;
// test if typography props still has the correct 'align' type
props.align = '';
// test B
declare const Test: PolyForwardComponent<'span', TypographyProps>;
// check if it works when used directly
<Test align='left' /> Simplest case is both |
Thanks for the response. I'm going to set up and test each of these cases. I will report back with my findings. |
I'm using your package to create polymorphic components that forward refs. Using the following pattern, everything works as intended within the local component library.
As I said, when used locally, such as in my Storybook examples, TypeScript sees and enforces the types.
However, after building the package with Rollup and importing it into another repository, all the types get genericized. This only happens on components wrapped with this polymorph utility.
Following the types, I see a logical chain to my eventual prop types that are correct.
I've traced other components that are not polymorphic and they all follow the same exact pattern, except the first step is a direct call to the React
forwardRefExcoticComponent
. These all type correctly.My question is, am I doing something incorrect at some step that could potentially cause this? Losing type safety on polymorphic components isn't good, so I need to figure out how to resolve this.
The text was updated successfully, but these errors were encountered: