Skip to content

[api-extractor] Fails to parse bundledPackages declarations from dir import #5412

@adventure-yunfei

Description

@adventure-yunfei

Summary

When using bundledPackages options, import declaration from dir generates incorrect dts result.

e.g. configure "bundledPackages": ["foo"], with following foo package files:

  • index.d.ts
    export { Bar } from './bar-dir';
  • bar-dir/index.d.ts
    export interface Bar {}

and following entry dts file:

export * from "foo";

generates dts result:

import { Bar } from './bar-dir';
export { Bar }

Repro steps

Expected result:

Previous example should generate:

export declare interface Bar {}

or reproduce by: https://github.com/adventure-yunfei/api-extractor-issue--bundledPackages

Details

Debugged and found the reason, introduced by #3321. For import declaration from dir (e.g., import { A } from "./a", while resolved file is a/index.d.ts), TypeScriptInternals.getResolvedModule (in ExportAnalyzer.ts) returns the result without packageId data, thus bundledPackages check is skipped (cause bug here).

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.53.1
Operating system? Mac
API Extractor scenario? rollups (.d.ts)
Would you consider contributing a PR? No
TypeScript compiler version? 5.8.2
Node.js version (node -v)? v16.20.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions