Repository navigation
fix(cli): a doc may leave out a value the code deprecates everywhere - #12456
josephfarina wants to merge 2 commits into
Conversation
`doctor integration components` (and the Core docs test) re-judge a type mismatch without the string values the package marks deprecated in every place the type takes them from: a union member under @deprecated, a @deprecated keyof key, or a @deprecated overload. A value any other form gives (a generic such as Exclude, an indexed access) stays required. FieldStatus variant leaves the known-drift list.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: the deprecated-value allowance works for @deprecated keyof keys and @deprecated overloads, but it misses the union-member form the guide promises once the source is Prettier-formatted.
commentDeprecates(prop-drift.mjs:924-930) sees a union member's@deprecatedcomment only on its own line after a trailing|; Prettier writes it before a leading|or inline after|, and both layouts still reporttype_mismatch, so read the comments between the previous member and this one and add tests in both layouts (or narrow the guide row, changeset and description to what works).- The description says
architecture:knowledge-contractsgoverns the doc-versus-type check, butarchitecture:cli-surfaceINV33 and DEC-5 do, so please cite those instead.
Non-blocking: a doc that drops one of two deprecated values and keeps the other is still reported, while the guide row says "a string value"; either remove only the values the doc leaves out or reword the row.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): the doctor components check no longer reports a doc that leaves out a value deprecated in every source. Partly false: true for deprecated
keyofkeys and deprecated overloads (new test fails on the base and passes on the head); false for union-member comments in Prettier layouts (probe). - Claim: the doctor check and Core's docs test compare documented prop types with the code. Verified (
api/integration/_adapter.mjs:22,test/core-prop-docs.test.mjs:16). - Claim: FieldStatus
variantwas on the known-drift list because of a deprecated value. Verified (itstooltipkey is deprecated inFieldStatus/index.ts:26-33; Core's prop-docs test passes on the head without the entry). - Claim: three deprecated sources are accepted. Verified for
keyofkeys and overloads; false for union-member comments in Prettier layouts. - Claim: a value any current source gives stays required, including
Exclude<…>and an indexed access. Verified (second new test). - Claim: with the fallback for unread type nodes removed, the second test fails. Verified by removing it.
- Claim: the authority is the knowledge-contracts doc checks. False:
architecture:cli-surfaceINV33 and DEC-5 govern the check. - Claim: no new public API, visual change, default or interaction model. Verified.
- Claim: no internal context in public text. Verified.
- Claim: tests, typecheck, Prettier and the knowledge check pass. Partly verified: the two covering test files pass, Prettier passes on the changed files, and CI typecheck and lint pass; the full local tally was not rerun.
- File
packages/cli/foundation/discovery/prop-drift.mjs: finding (union-member comment detection; partial omission note). - File
packages/cli/foundation/discovery/prop-drift.test.mjs: finding (the union-member fixture uses a layout Prettier never writes). - File
packages/cli/assets/docs/tree/check-the-props.doc.mjs: finding (the row promises the union-member form in general). - File
.changeset/prop-drift-deprecated-values.md: finding (same claim as the row); format valid. - File
packages/cli/test/core-prop-docs.known-drift.json: clear.
| const current = types | ||
| .flatMap(type => (type.isUnion() ? type.types : [type])) | ||
| .filter(part => !(part.isStringLiteral() && deprecated.has(part.value))); | ||
| return judgeType(docType, current, {...ctx, written: []}) === 'match' |
There was a problem hiding this comment.
Non-blocking: this removes every deprecated literal at once. With two deprecated members, a doc that drops one and keeps the other is still reported ('sm' | 'md' | 'lg' against 'sm' | 'md' | 'lg' | 'xl', both of the last two deprecated). The guide row says a doc may leave out "a string value". Remove only the deprecated literals the doc leaves out, or word the row "the string values".
A member's @deprecated comment may sit on its own line before a leading `|` or inline after the `|`; a comment on the line of the member before belongs to that member. TypeScript's own comment ranges place them.
There was a problem hiding this comment.
Approved pending CI: the CI jobs did not run on this head because the CI queue was full, so they need a re-run.
Both earlier blocking points are fixed: a union member's @deprecated comment is now read in every layout Prettier writes (on its own line before a leading |, inline after |, and above the first member), and the description cites architecture:cli-surface INV33 and DEC-5.
Non-blocking: the second pass drops every deprecated value at once (prop-drift.mjs:895-898), so a doc that keeps one deprecated value and drops another, or that describes one member of a union of props types, is still reported; either word the guide row and changeset "every string value the code marks deprecated" or strip only the values the doc leaves out, per member.
Claims and files checked
Review mode: incremental; reason: none
- Claim (changeset): the doctor components check no longer reports a documented string union that leaves out a value deprecated in every source. Verified for a doc that leaves out every deprecated value (the new tests fail on the earlier code and pass on the head); a doc that keeps one of two deprecated values is still reported (non-blocking note above).
- Claim: the doctor check and Core's docs test compare documented prop types with the code. Verified (
api/integration/_adapter.mjs:22,test/core-prop-docs.test.mjs:16). - Claim: FieldStatus
variantsat on the known-drift list because of a deprecated value. Verified (deprecatedtooltipkey inFieldStatus/index.ts:26-33and deprecated overload inFieldStatus.tsx:151-158; Core's prop-docs test passes on the head without the entry). - Claim: a value deprecated as a union member, a
keyofkey or an overload parameter may be left out. Verified (first and second new tests; probes of each layout). - Claim: a value any current source gives stays required, including
Exclude<…>and an indexed access. Verified (third new test). - Claim: with the fallback for unread type forms removed, that test fails. Verified by removing it.
- Claim: the comment is read where Prettier writes it, a comment on the previous member's line stays with that member, and the earlier reader fails the layout test on exactly those members. Verified (the earlier reader reports only
Box.gapandBox.sizebeyond the expectedBox.pad; Prettier's output matches the fixtures). - Claim:
architecture:cli-surfaceINV33 and DEC-5 govern the check, with the guide row. Verified. - Claim: no new public API, visual change, default or interaction model. Verified.
- Claim: no internal context in public text. Verified.
- Claim: tests, typecheck, Prettier and the knowledge check pass. Partly verified: the prop-drift and Core prop-docs tests and 82 CLI test files pass, and Prettier, the changeset check and the knowledge check pass; the strict CLI typecheck reports no error in the changed files, only two template imports of an unbuilt theme package.
- File
packages/cli/foundation/discovery/prop-drift.mjs: non-blocking notes (all-at-once removal at lines 895-898; a comment that only mentions@deprecatedcounts at lines 939-941). - File
packages/cli/foundation/discovery/prop-drift.test.mjs: clear. - File
packages/cli/assets/docs/tree/check-the-props.doc.mjs: non-blocking (the row says "a string value"). - File
.changeset/prop-drift-deprecated-values.md: non-blocking (same wording); format valid. - File
packages/cli/test/core-prop-docs.known-drift.json: clear.
| ...(ts.getLeadingCommentRanges(text, start) ?? []), | ||
| ...(ts.getTrailingCommentRanges(text, start) ?? []), | ||
| ].some((/** @type {any} */ range) => | ||
| text.slice(range.pos, range.end).includes('@deprecated'), |
There was a problem hiding this comment.
Non-blocking: .includes('@deprecated') also matches a comment that only mentions the word, so | /** Replaces the @deprecated big size. */ 'lg' marks 'lg' deprecated and a doc may leave it out unreported. Matching the tag only where JSDoc puts one, at the start of a comment line, avoids that.
PR Analysis Report🔎 Preview ·
|
|
/approve-spec 6933b8b |
- #12941 fix(Table): the default cell renderer shows an Invalid Date as an empty cell Author: @josephfarina - #12886 docs(core): the README setup loads the theme's fonts Author: @josephfarina - #12887 fix(cli): doctor --built reads the setup stylesheet as wiring, not page styling Author: @josephfarina - #12456 fix(cli): a doc may leave out a value the code deprecates everywhere Author: @josephfarina - #12857 docs(cli): the styling and typography pages state their core rules Author: @josephfarina - #12994 test(cli): the doctor golden leaves out a check only some computers report Author: @josephfarina - #13001 test(cli): the swizzle proof renders Lab's MediaPlayer with its required label Author: @josephfarina
|
Landed in #12992. |
User impact
astryx doctor integration components, and Core's own docs test, compare each documented prop type with the code. A doc that leaves out a string value the code keeps only for compatibility, marked@deprecated, read as drift, so a doc had to list a value the code tells people not to use (FieldStatusvariantsat on the known-drift list for this reason).Problem and solution fit
The check now lets a doc leave out a string value the code marks deprecated in every place the type takes it from: a union member under
@deprecated, a@deprecatedkey of akeyofmap, or a@deprecatedoverload's parameter. A value any current source gives stays required, including one a type node the check does not read structurally still names (a generic such asExclude<All, 'xs'>, an indexed access such asBase['size']). FieldStatusvariantleaves the known-drift list.Expected behavior and authority
architecture:cli-surfaceINV33 and DEC-5 say what the doc-versus-type check counts as drift (with the check-the-props guide row); this change says how a deprecated value counts.Smallest restoration
packages/cli/foundation/discovery/prop-drift.mjs: the deprecated-value allowance.packages/cli/test/core-prop-docs.known-drift.json: FieldStatusvariantremoved.Evidence
prop-drift.test.mjs: a value deprecated in every source may be left out, and one a current source gives stays required (both directions);Exclude<…>and an indexed access keep their current value required. With the fallback for unread type nodes removed, the second test fails.The deprecation comment is read where Prettier writes it, by TypeScript's own comment ranges: on its own line before a leading
|, inline after|, and after a trailing|; a comment on the line of the member before stays with that member. With the earlier reader, the layout test fails on exactly those members.Scope
Testing
pnpm check:knowledge.