Typedoc: Re-exporting interface in namespace via export import is considered a "variable"

Created on 23 Aug 2020  路  4Comments  路  Source: TypeStrong/typedoc

Re-exporting interface in namespace via export import is considered a "variable"

Search terms


namespace, aliasing, import, export, re-exporting, interface

Expected Behavior

TypeDoc will produce a web-page consisting of two interfaces listed for the following code:

/**
 * Sample namespace exported that leverages aliasing. 
 */
export namespace admin.subnamespace{
  export import DemoInterface = demoInterfaceApi.DemoInterface; // DOES NOT WORK!
  export interface DemoClass extends demoClassApi.DemoClass {}
}

Actual Behavior

The following appears with variables as one of the sections:

Steps to reproduce the bug

Visit my repository: github.com/MathBunny/typedoc-namespace-bug-demo

  • All the source code is found in src
  • You can test and build via npm run build && npm run docs

This seems related to #1157 but I'm not sure if export import is fully supported yet or what the plans are for it; the issues aren't very clear on what is and what is not supported yet.

Environment

  • Typedoc version: 0.18.0
  • TypeScript version: 3.9.5
  • Node.js version: v12.18.1
  • OS: macOS High Sierra 10.13.3
bug help wanted

Most helpful comment

This is fixed in the 0.20 beta running typedoc on the following:

export namespace NamespaceA {
    export interface InterfaceA { }
    //export type renamedInterfaceA =  InterfaceA; // WA to typedoc v0.15
}
export namespace NamespaceB {
    export interface InterfaceA { }
}
export namespace NamespaceC {
    export import renamedInterfaceA = NamespaceA.InterfaceA;
    export import InterfaceA = NamespaceB.InterfaceA;

    export class TestClass {
        testMethod1(options: renamedInterfaceA): any {}
        testMethod2(options: InterfaceA): any {};
    }
}

and then viewing NamespaceC shows the following, with the InterfaceA links going to the appropriate page:

image

All 4 comments

Adding to this, it also appears that enums aren't recognized correctly either, and they're labelled as variables.

export const AppPlatform: typeof appMetadataApi.AppPlatform = appMetadataApi.AppPlatform;

Here, appPlatform is an enum. The other option is to do:

export import AppPlatform = appMetadataApi.AppPlatform;

This doesn't seem to work either.

export import DemoInterface = demoInterfaceApi.DemoInterface;

TIL this is legal... Every other time I've only seen import = used to import something as a variable, as in the handbook - https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require. Looks like a bug.

export const AppPlatform: typeof appMetadataApi.AppPlatform = appMetadataApi.AppPlatform;

This is a variable. TypeDoc's output is correct here. The export import variant should be parsed as a re-export, but isn't.

The chanes in #1157 were focused on the more standard export { a, b } used in modules, not namespaces.

Right now, TypeDoc has ImportEquals handled in the variable converter, it should really get its own converter which converts as re-exports.

That makes sense, thanks for following up. Okay, the focus of this issue should remain on the export import aspect.

This is fixed in the 0.20 beta running typedoc on the following:

export namespace NamespaceA {
    export interface InterfaceA { }
    //export type renamedInterfaceA =  InterfaceA; // WA to typedoc v0.15
}
export namespace NamespaceB {
    export interface InterfaceA { }
}
export namespace NamespaceC {
    export import renamedInterfaceA = NamespaceA.InterfaceA;
    export import InterfaceA = NamespaceB.InterfaceA;

    export class TestClass {
        testMethod1(options: renamedInterfaceA): any {}
        testMethod2(options: InterfaceA): any {};
    }
}

and then viewing NamespaceC shows the following, with the InterfaceA links going to the appropriate page:

image

Was this page helpful?
0 / 5 - 0 ratings