Skip to content

typespec-ts: stop relying on api-extractor internal _defaultConfig in spector test harness #5370

Description

@iscai-msft

Problem

packages/typespec-ts/test/commands/run.ts builds an api-extractor config in memory (no api-extractor.json on disk) and relies on the private ExtractorConfig._defaultConfig static to get the built-in defaults:

structuredClone((ExtractorConfig as any)._defaultConfig)

In @microsoft/api-extractor 7.59.0, this internal was moved from a static class property to a module-level constant, so ._defaultConfig returns undefined and the config merge crashes with:

TypeError: Cannot read properties of undefined (reading 'apiReport')

This breaks every declaration-rollup emit in the Spector e2e job.

Current workaround

PR #5212 pins @microsoft/api-extractor to ~7.58.1 via an override in pnpm-workspace.yaml to avoid resolving 7.59.0.

Proposed fix

Replace the _defaultConfig access with one of:

  • Loading schemas/api-extractor-defaults.json directly via JsonFile.load from @rushstack/node-core-library (the file is JSONC, so plain JSON.parse won't work)
  • Using a supported public API if one exists for getting default config values
  • Restructuring the test to use ExtractorConfig.loadFile with a temporary config file

Once fixed, the @microsoft/api-extractor override can be removed from pnpm-workspace.yaml.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    emitter:typescriptIssues for @azure-tools/typespec-ts emitter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions