TypeScript: Module Augmentation fails when exports are declared in an ExportClause
TypeScript Version:
nightly (1.9.0-dev.20160502)
Code
// ext1.d.ts
declare module "State" {
interface IState {
num: number;
}
export { IState };
}
// ext2.d.ts
declare module "State" {
interface IState {
str: string;
}
export { IState };
}
//app.ts
import { IState } from "State";
function test(state: IState): void {
console.log(state.num);
console.log(state.str);
}
// tsconfig.json
{
"files": [
"app.ts",
"ext1.d.ts",
"ext2.d.ts"
]
}
Expected behavior: The “State” module and IState interface declarations should be merged and the code should compile without errors.
Actual behavior:
The declaration files report error TS2300: Duplicate identifier 'IState'
Workaround:
The above errors do not occur when both IState interfaces are exported inline using the export modifier instead of in a ExportClause.
NOTE: If the first is exported inline and the second is exported in an ExportClause then the second declaration errors with TS2482: Export declaration conflicts with exported declaration of 'IState'.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (9 by maintainers)
We’re seeing a similar error. After doing
npm install ag-grid --save, we tried to augment the module as follows.On build with
tsc 2.4.1we see the following error:We have also tried this approach:
In that case, the actual behavior is that the
ColDefinterface now has only thestrproperty.