Typescript React引导类型明确:错误TS2309:导出分配不能在具有其他导出元素的模块中使用
我刚刚升级了react bootstrap的打字功能,发现错误: 错误TS2309:导出分配不能在具有其他导出元素的模块中使用 在这一行:Typescript React引导类型明确:错误TS2309:导出分配不能在具有其他导出元素的模块中使用,typescript,react-bootstrap,typescript-typings,Typescript,React Bootstrap,Typescript Typings,我刚刚升级了react bootstrap的打字功能,发现错误: 错误TS2309:导出分配不能在具有其他导出元素的模块中使用 在这一行: declare namespace ReactBootstrap { // Import React import React = __React; //definitions omitted } declare module "react-bootstrap" { export = ReactBootstrap; //Er
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.
}
定义文件是错误的还是我做错了什么?好的,在我的例子中,我以前写过我自己的定义,因为它们在明确键入的打字中丢失了: 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 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中删除重复的定义修复了错误
declare namespace ReactBootstrap {
// Import React
import React = __React;
//all typings listed here, including InputGroupAddon which was previously missing
}
declare module "react-bootstrap" {
export = ReactBootstrap;
}