Using `as` prop throws error when using TypeScript
See original GitHub issueThe problem
Using the as
prop on TwComponent
and StyledComponent
raises an error when using TypeScript. Not sure if the problem is directly related to twin.macro
:
Property 'as' does not exist on type 'IntrinsicAttributes & ClassAttributes<HTMLAnchorElement> & AnchorHTMLAttributes<HTMLAnchorElement>'
Although using the prop works as expected in production if you use // @ts-expect-error
to sidestep the issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React component throwing TypeScript error for function ...
The first param to Component type is props type , and you have not defined it, therefore the error. Define a interface, interface...
Read more >Typescript component does not throw error if different prop ...
I am in the process of migrating my React project to typescript. I've managed to convert a smaller component and it's working as...
Read more >Documentation - JSX - TypeScript
Using JSX with TypeScript. ... but <bar /> will result in an error since it has not been specified on JSX. ... props;...
Read more >typescript react component type as prop - Industry Today
The ref is set when the element is declared using the ref prop: If a different element than div is used, the Typescript...
Read more >Typing Component Props - React TypeScript Cheatsheets
Basic Prop Types Examples. A list of TypeScript types you will likely use in a React+TypeScript app: type AppProps = { message: string;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update! I just got it to work (I think).
I’ve updated twin’s typescript docs to include the workaround.
Feel free to reopen if you want to adjust the core typings.