Skip to content

Commit eb55348

Browse files
committed
fix(scripts): declare the three workspace-enumerator exports the widened gate imports (#15682)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4138K1EG7kQ81FNba5Kp4
1 parent 8c12a91 commit eb55348

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

scripts/workspace-enumerator.d.mts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Types for the three `workspace-enumerator.mjs` exports a gate under
2+
// `packages/spec/scripts/` consumes — the same problem, and the same fix, as
3+
// `check-regen-pending.d.mts` and `js-comment-mask.d.mts` next door (#5475).
4+
//
5+
// The module itself stays `.mjs`: it is imported by root gates that run under
6+
// bare `node`, and it is deliberately NOT a gate of its own (see its header —
7+
// being one is exactly what it must not be). What changed is that
8+
// `check-duration-unit-keys.ts` now imports it (#15682, when that gate's
9+
// population widened from `packages/spec/src/**` to every workspace package's
10+
// `src/`), and since #5475 that directory sits inside a tsc program
11+
// (`tsconfig.scripts.json`), where an untyped `.mjs` import is TS7016 — the
12+
// enumeration silently becomes `any`, and a misspelled export would type-check
13+
// clean while resolving to `undefined` at runtime.
14+
//
15+
// PARTIAL BY DESIGN, the shape `check-regen-pending.d.mts` already takes and
16+
// `check:declaration-mirrors` explicitly sanctions: the module exports twelve
17+
// names and this declares the THREE this repo's TypeScript consumers use.
18+
// Importing an undeclared name from here is `TS2305` — loud, red and immediate
19+
// — never a silent `any`. Declared rather than inferred (no `allowJs`) because
20+
// the module sits at the repo root, outside the consuming program's `rootDir`.
21+
// Keep this file in step with the module by hand; `check:declaration-mirrors`
22+
// holds the names, kinds and required arities.
23+
24+
/**
25+
* The `packages:` globs of the workspace rooted at `root`.
26+
*
27+
* A MISSING `pnpm-workspace.yaml` is this function's refusal, not an empty
28+
* answer — callers for whom "no workspace here" is ordinary test with
29+
* `existsSync` first.
30+
*/
31+
export function readWorkspaceGlobs(root: string): string[];
32+
33+
/** Whether a glob is a pnpm exclusion (`!pattern`), which enumerates nothing. */
34+
export function isExclusionGlob(glob: string): boolean;
35+
36+
/**
37+
* Every workspace member that actually holds a `package.json`, as repo-relative
38+
* POSIX directories, sorted.
39+
*/
40+
export function workspacePackageDirs(root: string): string[];

0 commit comments

Comments
 (0)