[英]Extend @typings in Typescript
I am writing a application using React and Typescript One of the components is using an ReactBootstrap.Overlay trigger, and I would like to use the none supported parameter "shouldUpdatePosition={true}" as argument. 我正在使用React和Typescript编写应用程序。组件之一是使用ReactBootstrap.Overlay触发器,我想使用不受支持的参数“ shouldUpdatePosition = {true}”作为参数。 However that parameter is not defined in the @types for react-bootstrap (and since it is a non-supported argument I guess that is correct) Is it possible to extend the @types from @types/react-bootstrap with this parameter?
但是,该参数未在@types中为react-bootstrap定义(并且由于它是不受支持的参数,我想这是正确的)是否可以使用此参数从@ types / react-bootstrap扩展@types?
My code looks like this: 我的代码如下所示:
import * as React from "react";
import * as ReactBootstrap from "react-bootstrap"
export interface IDetailsPopoverProps {
placement?: string;
}
export class DetailsPopover extends React.Component<IDetailsPopoverProps, any> {
public render(): JSX.Element {
var detailsPopover = <ReactBootstrap.Popover id={this.props.id} className="details-popover">
{this.props.children}
</ReactBootstrap.Popover>;
return (
<div className="details-popover-container">
<ReactBootstrap.OverlayTrigger
ref="trigger"
container={this}
//This is the parameter which does not exist in @types
shouldUpdatePosition={true}
trigger="click"
rootClose placement={this.props.placement ? this.props.placement : "bottom"}
overlay={detailsPopover}>
<span className="details-popover-trigger">
<b className="caret"></b>
</span>
</ReactBootstrap.OverlayTrigger>
</div>
);
}
}
Add something like this declaration to your file: 将类似此声明的内容添加到您的文件中:
declare module "react-bootstrap/lib/OverlayTrigger" {
interface OverlayTriggerProps {
shouldUpdatePosition: boolean;
}
}
Here's the handbook page I assume Aluan Haddad was talking about. 这是我认为Aluan Haddad在说的手册页 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.