Merge pull request #30046 from Igorbek/dt-issue30042

[styled-components] Fix #30042
This commit is contained in:
Igor Oleinikov 2018-10-25 23:16:14 -07:00 committed by GitHub
commit 33937378a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -82,7 +82,7 @@ export interface ThemedStyledFunction<P, T, O = P> {
strings: TemplateStringsArray,
...interpolations: Array<Interpolation<ThemedStyledProps<P & U, T>>>
): StyledComponentClass<P & U, T, O & U>;
attrs<U, A extends Partial<P & U> = {}>(
attrs<U, A extends Partial<P & U> & { [others: string]: any; } = {}>(
attrs: Attrs<P & U, A, T>,
): ThemedStyledFunction<DiffBetween<A, P & U>, T, DiffBetween<A, O & U>>;
}

View File

@ -312,6 +312,12 @@ const AttrsInput = styled.input.attrs({
padding: ${props => props.padding};
`;
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/30042
const AttrsWithOnlyNewProps = styled.h2.attrs({ as: 'h1' })`
color: ${props => props.as === 'h1' ? 'red' : 'blue'};
font-size: ${props => props.as === 'h1' ? 2 : 1};
`;
/**
* component type
*/