Skip to content

Instantly share code, notes, and snippets.

@fanyang89
Created February 26, 2018 08:36
Show Gist options
  • Save fanyang89/27fd8c344e03c810b80d4d30a3c021d6 to your computer and use it in GitHub Desktop.
Save fanyang89/27fd8c344e03c810b80d4d30a3c021d6 to your computer and use it in GitHub Desktop.
Provide props to styled elements in Typescript
import * as React from "react";
import { ThemedStyledFunction } from "styled-components";
const themed = <IComponentProps, U extends HTMLElement = HTMLElement>(
styled: ThemedStyledFunction<any, any>,
): ThemedStyledFunction<IComponentProps & React.HTMLProps<U>, any> => styled;
export default themed;
// eg.
// import styled, { StyledComponentClass } from "styled-components";
// import themed from "../themed";
// const Foo = themed<IFooProps>(styled.div)`
// width: 100%;
// `;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment