Reputation:
I have a external library which exports:
import * as React from 'react';
import { BsPrefixComponent } from './helpers';
export interface ListGroupItemProps {
action?: boolean;
active?: boolean;
disabled?: boolean;
variant?:
| 'primary'
| 'secondary'
| 'success'
| 'danger'
| 'warning'
| 'info'
| 'dark'
| 'light';
}
declare class ListGroupItem<
As extends React.ReactType = 'a'
> extends BsPrefixComponent<As, ListGroupItemProps> {}
export default ListGroupItem;
How can I use the variant as a type in my own interface? I am trying to do something like:
import ListGroupItemProps from 'react-bootstrap/ListGroup';
export interface Message {
from?: string;
content?: string;
variant?: ListGroupItemProps.variant;
}
Upvotes: 0
Views: 55
Reputation: 249466
You can use a index type query:
import { ListGroupItemProps } from 'react-bootstrap/ListGroup';
export interface Message {
from?: string;
content?: string;
variant?: ListGroupItemProps['variant'];
}
Upvotes: 1