Commit 2473353
authored
ci(superdoc): per-file checkJs gate for public-contract drift (SD-2863) (#3044)
* ci(superdoc): per-file checkJs gate for public-contract drift (SD-2863)
The existing audit gates (declarations, consumer matrix, public-type
assertion list) all check the published artifact. None of them catch
the case where a public JSDoc typedef drifts from the implementation
that consumes it — the IT-300 / IT-338 / SD-2514 class. Enabling
project-wide `checkJs: true` cascades through `customConditions:
["source"]` resolution and surfaces ~6500 errors across 439 files,
which is its own multi-PR ratchet rather than a gate.
Lands the per-file pattern instead: each file in the gate adds
`// @ts-check`, the gate script runs `tsc --noEmit` against the
existing project tsconfig and filters output to the curated file list.
A regression on a gated file fails CI; pre-existing errors elsewhere
are ignored and tracked under follow-up tickets.
First file under the gate is `packages/superdoc/src/helpers/
schema-introspection.js`. The probe immediately surfaced one real drift:
the `extensions` parameter was typed `Array` (no type argument), which
collapses to `Array<any>` for consumers — exactly the SD-2514 class.
Replaced with `NonNullable<EditorOptions['extensions']>` so the
parameter pulls its real shape from the public `EditorOptions` type.
Adding more files later: add `// @ts-check` as the first line and
append the path to `CHECKED_FILES` in `check-jsdoc.cjs`. Follow-up
tickets cover the next files (use-find-replace, use-password-prompt,
SuperDoc.js, etc.) one at a time.
* ci(superdoc): fail check:jsdoc on tsc invocation errors (SD-2863)
The gate scanned tsc output for diagnostics in CHECKED_FILES, but did
not check whether tsc actually ran. Two silent-pass modes existed:
- spawnSync sets result.error (e.g. ENOENT on a missing tsc binary,
signal, permission denied). result.status is null, stdout/stderr are
empty, and the script reports OK.
- tsc exits non-zero with a structural error (missing tsconfig, internal
crash) that does not match the (line,col) regex. allErrors is empty,
so the gate reports OK on a build that never type-checked anything.
Both now exit 1 with the captured failure context.
* ci(superdoc): require @ts-check on gated files and fail on signal kill (SD-2863)
Reviewer flagged two more silent-pass modes the previous patch missed:
- A path can be in CHECKED_FILES without the file containing
`// @ts-check`. Because the project tsconfig sets `checkJs: false`,
TypeScript skips the file entirely, allErrors stays empty, and the
gate reports OK even though the file has fully drifted.
- spawnSync can return with `result.status === null` and `result.signal`
set when tsc is killed by a signal (SIGKILL/OOM/SIGTERM) mid-run. If
the partial output happens to contain parseable diagnostics that
match no gated file, the structural-failure branch does not fire.
Both fail explicitly now. Pre-flight refuses to run tsc unless every
gated file exists and contains `// @ts-check` in its first 4 KiB; the
post-spawn check fails on `result.signal !== null`. Verified locally
by deleting the directive and by killing a fake tsc with SIGKILL.1 parent 7eb7412 commit 2473353
4 files changed
Lines changed: 171 additions & 1 deletion
File tree
- .github/workflows
- packages/superdoc
- scripts
- src/helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
0 commit comments