diff --git a/types/styled-components/index.d.ts b/types/styled-components/index.d.ts index c6210edf91..f436b8d490 100644 --- a/types/styled-components/index.d.ts +++ b/types/styled-components/index.d.ts @@ -82,7 +82,7 @@ export interface ThemedStyledFunction { strings: TemplateStringsArray, ...interpolations: Array>> ): StyledComponentClass

; - attrs = {}>( + attrs & { [others: string]: any; } = {}>( attrs: Attrs

, ): ThemedStyledFunction, T, DiffBetween>; } diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index 8adfb03307..7f2197389f 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -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 */