Closed
Description
I was trying to write some type definition for the styled-components project, but it looks like there is no way to specify a generic when using a tagged template. So... here is a subset of the typedef I'm writing:
declare module 'styled-components' {
import * as React from "react";
export function input<P>(values: TemplateStringsArray): React.StatelessComponent<P>;
}
This is how I'd like to use it:
import * as React from 'react';
/// <reference path="../../../typings/styled-components/styled-components.d.ts" />
import styled from 'styled-components';
interface Props {
placeholder: string;
}
const Input = styled.input<Props>`
font-size: 1.5em;
text-align: center;
color: palevioletred;
`;
I know that it can also be possible to override Input.propTypes manually[1], but I was wondering if this could be an useful addition to Typescript.
TypeScript Version: 2.0.3
[1] Or even write a custom component and just use the styled(Component)
style`` syntax