Created
November 5, 2020 12:18
-
-
Save 3cL1p5e7/5529ab48cc0c3429d94dbe32af837399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from 'styled-components'; | |
import { AddComponentProps } from '@midhub/components/dist/utils/AddComponentProps'; | |
// example 1 | |
const TestComponent = <C extends React.ElementType = 'button'>( | |
p: AddComponentProps<{ text: number }, C> | |
) => <span>{p.text}</span>; | |
const TestComponentStyled = styled(TestComponent)``; | |
// Problem hehe | |
export const Test1 = () => <TestComponentStyled test='1' text={22} />; // typecheck DOES NOT throws error for `test` property | |
export const Test2 = () => <TestComponent test='1' text={22} />; // typecheck THROWS error for `test` property | |
// example 2 | |
const TestComponent2 = ( | |
p: { text: number } | |
) => <span>{p.text}</span>; | |
const TestComponentStyled2 = styled(TestComponent2)``; | |
export const Test3 = () => <TestComponentStyled2 test='1' text={22} />; // typecheck THROWS error for `test` property |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment