typespec-ts: stop relying on api-extractor internal `_defaultConfig` in spector test harness
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
## 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:
```ts
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`.
Contributor guide
Research direction
Start in packages/typespec-ts/test/commands/run.ts and inspect how the in-memory api-extractor configuration obtains defaults; review schemas/api-extractor-defaults.json and the pnpm-workspace.yaml override. Run the Spector declaration-rollup emit with api-extractor 7.59.0. Done means the emit succeeds without accessing _defaultConfig and the override can be removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100