Repository navigation
Commit 98bd8de
fix(adr-0087-gate): a type alias after a semicolon-less statement keeps its body a type body (#38231)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDypKu7B9nwbu5WuV7AEio8)_
Fixes #38207
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户无感:只改发版前检查破坏性改动的内部工具,前后差别在于它能正确读出写在无分号语句之后的类型定义。
- 为什么做:发版登记检查此前会把这类类型的成员误判为「没有标注」,本该拦下的收窄改动可能被放行。
- 出错会怎样:最坏是该检查对个别写法误判,只影响内部检查结果,可直接撤回本改动。
- 要你做的:无。
## What changes
`scripts/check-adr-0087-registration.mjs`, `braceOpensTypeBody`: the
`type X =` alias test now reads the LAST statement inside the header
`braceHeader` collects (new `headerStatement`), not the header's start.
The statement start is the file's existing `NEXT_STATEMENT_RE` (keyword
at a word boundary) behind the `RHS_CONTINUES_RE` boundary, the same ASI
boundary `aliasRhsEnd` already reads. The boundary can only move the
start later, so it never widens the reading toward the value side; only
the alias test reads it (the `interface`/`class` test and the rest are
byte-unchanged).
The same mechanism had a mirror defect, fixed by the same line: after a
ONE-LINE alias with no `;` (`type S = A`), the next value literal's
header began with `type`, so `const o: S = { f: () => null }` read `f`
as a function TYPE returning `null` (a value called concrete). TSO-U49
pins it; it is red at `origin/main` too.
Pins (battery `TSO-U`, floor 45 to the measured 49):
- TSO-U46: the card's minimal repro.
- TSO-U47: the real `sidebar.tsx` `SidebarContextProps` shape
(multi-line import, three `const` lines, no `;`): `setOpen`,
`setOpenMobile`, `toggleSidebar` read `void`.
- TSO-U48: lit control, the same alias after a `;`.
- TSO-U49: value-direction control, a value literal after a `;`-less
alias stays an unannotated VALUE (sidebar head and a one-line alias).
TSO-U43 (the ThemeProvider shape) stays green.
## Tests
<details><summary>Sidebar instance, origin/main f294277 vs this
head</summary>
`readTypeSurfaceRef(text,
parseSymbolRef('ui/packages/components/src/ui/sidebar.tsx#SidebarContextProps.X'))`:
```text
== origin/main f294277
...#SidebarContextProps.setOpen -> {"shape":"`SidebarContextProps.setOpen`, which carries NO return annotation","type":null,"erased":true}
...#SidebarContextProps.setOpenMobile -> {"shape":"... which carries NO return annotation","type":null,"erased":true}
...#SidebarContextProps.toggleSidebar -> {"shape":"... which carries NO return annotation","type":null,"erased":true}
== head
...#SidebarContextProps.setOpen -> {"shape":"the return annotation of `SidebarContextProps.setOpen`","type":"void","erased":false}
...#SidebarContextProps.setOpenMobile -> {"shape":"the return annotation of `SidebarContextProps.setOpenMobile`","type":"void","erased":false}
...#SidebarContextProps.toggleSidebar -> {"shape":"the return annotation of `SidebarContextProps.toggleSidebar`","type":"void","erased":false}
```
</details>
<details><summary>Self-test at dd09524</summary>
`node scripts/check-adr-0087-registration.mjs --self-test` exit 0: `✓
check-adr-0087-registration --self-test: 871 assertions over real temp
git repos`. Every existing pin green (TSO-U31..U45, TSO-I, R8, R9, G2).
Floor check: with the `TSO-U` floor set to 50 the self-test reds with
`registered 49 case(s), below its pinned floor of 50`, so 49 is the
measured count.
</details>
<details><summary>Ablation (fix reverted through
scripts/ablation-replace.mjs)</summary>
Anchor `.test(headerStatement(header)) && header.endsWith('=')` replaced
by `.test(header) && header.endsWith('=')` (anchor 1 -> 0, blob
34381d4 -> 6dc33f1d322b). Self-test exit 1, failing exactly
TSO-U46, TSO-U47 and TSO-U49; TSO-U48 (lit control) stays green.
Restore: blob == HEAD (34381d4), `git diff HEAD` empty.
</details>
## Acceptance notes
- TSO-U49 is red at `origin/main` as well (the mirror direction above),
so it is a fix pin as much as a control; it is the same mechanism in the
same function, fixed by the same line, no separate card.
## Verification
Read first: `headerStatement` and its one call in `braceOpensTypeBody`
(the only behaviour change).
Two-minute check: `node scripts/check-adr-0087-registration.mjs
--self-test` prints the 871-assertion success line.
<details><summary>Local gates at dd09524</summary>
`node scripts/pm/dispatch-gates.mjs --commands`: 34 commands, all run,
all exit 0 (including `pnpm check:pm-dispatch-gates`, 2369 cases).
`--ran` reconciliation: `34 derived famil(ies) accounted for — 34 run, 0
NOT-MEASURED (a DERIVED zero)`. `overlap-check`: `VERDICT clean exit 0`.
No changeset: the diff touches only the private root package's
`scripts/`, which publishes nothing (`skip-changeset`).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a262197 commit 98bd8de
1 file changed
Lines changed: 53 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
3693 | 3693 | | |
3694 | 3694 | | |
3695 | 3695 | | |
3696 | | - | |
| 3696 | + | |
3697 | 3697 | | |
3698 | 3698 | | |
3699 | 3699 | | |
| |||
3741 | 3741 | | |
3742 | 3742 | | |
3743 | 3743 | | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
3744 | 3771 | | |
3745 | 3772 | | |
3746 | 3773 | | |
| |||
8043 | 8070 | | |
8044 | 8071 | | |
8045 | 8072 | | |
| 8073 | + | |
| 8074 | + | |
| 8075 | + | |
| 8076 | + | |
| 8077 | + | |
| 8078 | + | |
| 8079 | + | |
| 8080 | + | |
| 8081 | + | |
| 8082 | + | |
| 8083 | + | |
| 8084 | + | |
| 8085 | + | |
| 8086 | + | |
| 8087 | + | |
| 8088 | + | |
| 8089 | + | |
| 8090 | + | |
| 8091 | + | |
| 8092 | + | |
| 8093 | + | |
| 8094 | + | |
| 8095 | + | |
| 8096 | + | |
8046 | 8097 | | |
8047 | 8098 | | |
8048 | 8099 | | |
| |||
0 commit comments