Skip to content

Conversation

adventure-yunfei
Copy link
Contributor

Summary

api-extractor generates invalid dts results for some namespace declaration cases. e.g.

Details

Code changes summary:

  • Analyzing phase: analyze "export { A as B }" node (which should be referenced by namespace)

  • Emitting phase:

    • fix export/default/declare modifier only for root declarations.
    • when renaming Identifier node, fix a special case for "export { A }"
  • Fixed [api-extractor] Re-exported import * namespaces produce malformed .d.ts rollups (with bundledPackages) #4807

  • Fixed [api-extractor] Namespace/Module Declaration has {}; at the end #3127

  • Fix unexpected export of actual un-exported declaration:
    input:

    export namespace PartalExportedNS {
      interface UnexportedClass { }
      export interface ExportedInterface {
        prop: UnexportedClass;
      }
    }

    expected output:

    export declare namespace PartalExportedNS {
      interface UnexportedClass {
      }
      export interface ExportedInterface {
        prop: UnexportedClass;
      }
      export { };
    }
    export { }

    actual output:

    export declare namespace PartalExportedNS {
      // This should not be exported
      export interface UnexportedClass {
      }
      export interface ExportedInterface {
        prop: UnexportedClass;
      }
      { };
    }
    export { }

How it was tested

Added a new namespaceDeclaration test case, and verified other test results.

Impacted documentation

@adventure-yunfei adventure-yunfei force-pushed the feat/api-extractor/fix-namespace-support branch from 8696260 to 0235c5d Compare September 9, 2025 02:31
@octogonz
Copy link
Collaborator

@adventure-yunfei Thanks for this fix!

Overall it looks good to me. I will merge it after testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs triage
2 participants