Repository navigation
fix(CodeBlock): without a code string, CodeBlock names the prop and the fix in development - #12395
josephfarina wants to merge 2 commits into
Conversation
…rop and the fix in development
…he fix in development
|
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.
Approved pending CI: CI has not run on this head yet.
In development, CodeBlock now names the code prop and the fix when code is not a string, and the production bundle is byte-identical to the base. The new test fails on the base and passes here, and I found no blocking issues. This pull request builds on #12386, which adds devPropError, so it lands after that one.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- The release note's patch
[fix]entry for@astryxdesign/core: verified, the changeset check passes and no public API changes. - In development, a render without a
codestring throws an error that namescodeand shows the fix: verified,CodeBlock.tsx:1055-1061and the "names the prop and the fix" test. - That error replaces a TypeError from inside the component, and production output is unchanged: verified, the new test receives
Cannot read properties of undefined (reading 'split')on the base, and the minified production bundle is byte-identical. - The change builds on #12386 for
devPropError, and only its top commit is under review: verified, the base branch is that pull request's head and the diff is one commit. - The example render throws that TypeError on the base, and the message names neither the component nor the prop: verified by the same test.
codeis a required string that CodeBlock splits into lines: verified,CodeBlock.tsx:592and:1086.- CodeBlock checks the prop first and throws the quoted message: verified,
CodeBlock.tsx:1055is the first statement and:1059matches the quote. - The prop's type in
CodeBlockPropsdefines the expected value: verified,code: stringatCodeBlock.tsx:592. - The error uses Core's
Component: messageform: verified,devPropErrorformats throughformatDevMessageinutils/devWarning.ts. - A single inline
NODE_ENVcheck throws the error, and a production bundle drops it: verified,CodeBlock.tsx:1055and the bundle check. - In production the same render throws the same TypeError as before: verified, the "keeps the production behavior" test passes on the base and here.
- The minified production output is byte-identical to the base: verified, same size and hash.
- The regression test covers the development message, the production behavior and a development-only message: verified,
CodeBlock.missingCode.test.tsx:41-69, and two of its three tests fail on the base. - The scope is CodeBlock: verified, only CodeBlock files and their release note change.
- The change restores one defect and carries no tagalongs: verified, it has one primary change.
- It adds no public API, visual representation, default or interaction model: verified, the API surface comparison finds no rows and
CodeBlock.d.tsis unchanged. - Public text carries no internal context: verified.
- The listed tests, typecheck, lint and formatting pass: verified, the CodeBlock tests (186), the Core typecheck, eslint and prettier pass at this head.
Files:
.changeset/codeblock-missing-code-error.md: clear.packages/core/src/CodeBlock/CodeBlock.tsx: clear.packages/core/src/CodeBlock/CodeBlock.missingCode.test.tsx: clear.
PR Analysis Report🔎 Preview ·
|
…he prop and the fix in development
- #12680 perf(cli): a template's component line resolves its names in one pass, not one full lookup per name Author: Joey <[email protected]> - #12180 fix(core): Calendar weekday names widen their column instead of overlapping Author: Joey <[email protected]> - #12159 feat(cli): make an icon set inside your own app Author: Joey Farina <[email protected]> - #12383 fix(Grid): a responsive column shrinks to a container narrower than minWidth Author: Joey Farina <[email protected]> - #12374 [fix] Icon: a glyph given as name renders and warns, instead of crashing Author: Joey Farina <[email protected]> - #12453 fix(charts): line, area and band default to straight segments Author: josephfarina <[email protected]> - #12296 fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill Author: Joey Farina <[email protected]> - #12395 fix(CodeBlock): without a code string, CodeBlock names the prop and the fix in development Author: Joey Farina <[email protected]> - #12260 fix(cli): `astryx component Flex` names Stack first Author: Joey Farina <[email protected]> - #12391 fix(core): a two-lane Toolbar wraps instead of squeezing its start lane Author: Joey Farina <[email protected]> - #12427 fix(core): checkbox and radio marks keep their share of the box a theme sizes Author: josephfarina <[email protected]> - #12725 [experimental] cli: with no icon set, experimental icon names the discover search where it lists packs Author: Joey Farina <[email protected]>
|
Landed in #12738. |
Builds on #12386 (merged), which adds the shared
devPropErrorhelper. Review the commits above it.User impact
A builder who writes
<CodeBlock language="ts">const a = 1;</CodeBlock>, as with<pre>, getsCannot read properties of undefined (reading 'split')from inside CodeBlock. The message names neither the component nor the prop.Problem and solution fit
codeis a required string; CodeBlock splits it into lines. In development, CodeBlock now checks the prop first and throws:Expected behavior and authority
The prop's type in
CodeBlockPropsdefines the expected value. The error uses Core'sComponent: messageform fromutils/devWarning.ts.Smallest restoration
One inline
process.env.NODE_ENV !== 'production'check that throwsdevPropErrorwhencodeis not a string. A production bundle drops it.Evidence
<CodeBlock language="ts">const a = 1;</CodeBlock>throwsCannot read properties of undefined (reading 'split').CodeBlock.missingCode.test.tsx(development message, production behavior, and the message is in a development bundle only).Scope
Components: CodeBlock
Testing
CI=1 vitest run --project uion the component's directory,tsc -p packages/core, eslint and prettier on the changed files.