我刚刚升级了react-bootstrap的输入,我收到了错误:
错误TS2309:导出分配不能在具有其他导出元素的模块中使用。
在这一行:
declare namespace ReactBootstrap {
// Import React
import React = __React;
//definitions omitted
}
declare module "react-bootstrap" {
export = ReactBootstrap; //Error TS2309: An export assignment cannot be used in a module with other exported elements.
}
定义文件是错误的还是我做错了什么?
答案 0 :(得分:1)
好的,在我的情况下,我之前已经编写了自己的定义,因为它们在绝对打字的类型中缺失:
<强> custom.d.ts:强>
declare module "react-bootstrap" {
// Import React
import React = require("react");
// <InputGroup.Addon>
interface InputGroupAddonProps extends React.HTMLAttributes {
}
class InputGroupAddon extends React.Component<InputGroupAddonProps, {}> {
}
}
来自明确打字的定义之前看起来像这样:
declare module "react-bootstrap" {
// Import React
import React = require("react");
//all typings listed here
}
但这已改为:
declare namespace ReactBootstrap {
// Import React
import React = __React;
//all typings listed here, including InputGroupAddon which was previously missing
}
declare module "react-bootstrap" {
export = ReactBootstrap;
}
我通过从custom.d.ts
中删除重复的定义来修复错误