2016-08-08 34 views
1

我剛剛升級的反應,引導分型和我得到的錯誤:陣營,引導肯定是類型的:錯誤TS2309:一個出口分配不能在模塊中使用與其他出口元素

Error TS2309: An export assignment cannot be used in a module with other exported elements.

上此行:

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. 
} 

定義文件錯了還是我做錯了什麼?

回答

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中的重複定義修復了錯誤

相關問題