Skip to content

[api-extractor] API Extractor cannot resolve ambient modules #3335

Description

@zelliott

Summary

If API Extractor is run on an entry point that re-exports a symbol from an ambient module, it's unable to resolve the ambient module, and thus throws an error.

Repro steps

  1. Clone https://github.com/zelliott/rushstack/tree/ambient-modules
  2. Run rush rebuild -o api-extractor-scenarios
  3. Observe the error in the ambientModule test scenario.

InternalError: Internal Error: getResolvedModule() could not resolve module name "bar"
/Users/zell/Developer/rushstack/build-tests/api-extractor-scenarios/lib/ambientModule/index.d.ts:2:1

Details

The problem seems to be in the TypeScript getResolvedModule helper. It doesn't seem to be able to resolve ambient modules. It's not clear to me if there's something wrong in my setup, if there's a bug in getResolvedModule, or if API Extractor has to use some other TS compiler API to resolve ambient modules.

Standard questions

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

Question Answer
@microsoft/api-extractor version? Latest
Operating system? All
API Extractor scenario? All
Would you consider contributing a PR? Yes
TypeScript compiler version? Latest
Node.js version (node -v)? Latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    AE/AD

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions