Skip to content

ctix does not support merged declarations properly #179

@MrGazdag

Description

@MrGazdag

The bug

Hi, I was working on a TypeScript project where I have a merged declaration of an interface and a namespace. This essentially means that the interface seemingly has static methods. This can be done with the following:

//test1.ts
interface Test1 {
  property: number
}
namespace Test1 {
  export function func() {
    console.log("hello world");
  }
}
export default Test1;

But for some reason, ctix produces a "type" export which then discards the namespace:

//barrel.ts
export { default as Test1 } from "./test1";

It seems that ctix looks at the first occurrence of the name Test, and does logic based on that, because if I flip the order of declarations in the code:

//test2.ts
namespace Test2 {
    export function func() {
        console.log("hello world");
    }
}
interface Test2 {
    property: number
}
export default Test2;

then the resulting file will contain a regular export:

//barrel.ts
export { default as Test2 } from "./test2";

Expected output

Since I have both a namespace and an interface, I'd like to keep both, so the expected output for any of the two test cases would be a regular export:

//barrel.ts
export { default as Test1 } from "./test1";
export { default as Test2 } from "./test2";

Actual output

//barrel.ts
export { type default as Test1 } from "./test1";
export { default as Test2 } from "./test2";

Here is the above in a .zip for easier testing: test.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions