diff --git a/CHANGELOG.md b/CHANGELOG.md index f995ac64b..adc887a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. If a contri - Added a test for `withComponent` followed by `attrs`, thanks to [@btmills](https://github.com/btmills). (see [#851](https://github.com/styled-components/styled-components/pull/851)) - Fix Flow type signatures for compatibility with Flow v0.47.0 (see [#840](https://github.com/styled-components/styled-components/pull/840)) - Upgraded stylis to v3.0. (see [#829](https://github.com/styled-components/styled-components/pull/829) and [#876](https://github.com/styled-components/styled-components/pull/876)) +- Added missing v2.0 APIs to TypeScript typings, thanks to [@patrick91](https://github.com/patrick91), [@igorbek](https://github.com/igorbek) (see [#837](https://github.com/styled-components/styled-components/pull/837), [#882](https://github.com/styled-components/styled-components/pull/882)) ## [v2.0.0] - 2017-05-25 diff --git a/typings/styled-components.d.ts b/typings/styled-components.d.ts index 8b98f2186..8ac9bbe21 100644 --- a/typings/styled-components.d.ts +++ b/typings/styled-components.d.ts @@ -20,7 +20,7 @@ export type OuterStyledProps

= ThemedOuterStyledProps; export type Interpolation

= FlattenInterpolation

| ReadonlyArray | ReadonlyArray>>; export type FlattenInterpolation

= InterpolationValue | InterpolationFunction

; -export type InterpolationValue = string | number; +export type InterpolationValue = string | number | StyledComponentClass; export type SimpleInterpolation = InterpolationValue | ReadonlyArray>; export interface InterpolationFunction

{ (props: P): Interpolation

; @@ -105,13 +105,13 @@ interface StylesheetComponentProps { sheet: ServerStyleSheet; } -export class StyleSheetManager extends React.Component { } +export class StyleSheetManager extends React.Component { } export class ServerStyleSheet { collectStyles(tree: React.ReactNode): ReactElement; getStyleTags(): string; - getStyleElement(): ReactElement[]; + getStyleElement(): ReactElement<{}>[]; } export default styled; diff --git a/typings/tests/nested-test.tsx b/typings/tests/nested-test.tsx new file mode 100644 index 000000000..de982b780 --- /dev/null +++ b/typings/tests/nested-test.tsx @@ -0,0 +1,30 @@ +import * as React from "react"; + +import styled, { css } from "../.."; + +const Link = styled.a` + color: red; +`; + +const AlternativeLink = styled.a` + color: blue; +`; + +const freeStyles = css` + background-color: black; + color: white; + ${Link} { + color: blue; + } +`; + +const Article = styled.section` + color: red; + ${freeStyles} + & > ${Link} { + color: green; + } + ${p => p.theme.useAlternativeLink ? AlternativeLink : Link} { + color: black + } +`;