Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sashless/bdba2f06d5677b944a66ed06fcdf38b9 to your computer and use it in GitHub Desktop.
Save sashless/bdba2f06d5677b944a66ed06fcdf38b9 to your computer and use it in GitHub Desktop.
How to add TypeScript prop type definitions to an existing React component
import * as React from 'react';
declare class SomeReactComponent extends React.Component<SomeReactComponentProps, any> {}
interface SomeReactComponentProps {
className?: string;
toggle?: boolean;
name: string;
size?: 'lg' | '2x' | '3x' | '4x' | '5x';
}
declare var SomeReactComponentType: typeof SomeReactComponent;
export = SomeReactComponentType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment