Repository navigation
EPBDS-16211 E2: seven stateful components, as TypeScript - #137
Merged
Merged
Conversation
ProgressBar, ProgressSteps, Counter, Pagination, Select, Dropzone and StandaloneTabs become .tsx with exported prop types (git mv, so their history follows). Upload's last component cast, Dropzone's, is deleted, and DropzoneHandle is now the real handle. forwardRef's own type runs props through Omit<..., 'ref'>, which keeps only the index signature of a type that has one, so Dropzone is cast to the same component with its props kept. Typing Select showed that InputNative's select branch hands it the engine onChange; the ForwardedProps comment said every branch overwrote it, and is corrected. StandaloneTabs renders an object tab without an icon as it is, which React rejects; demo-only, recorded and not fixed. Measured: the 38-example corpus is identical to master (107 / 1013 / 27 / 64, same DOM); dist/index.js 327,399 -> 327,387 bytes (Upload's Dropzone alias is gone); TypeScript is 49.7% of src/core + src/library lines, was 44.4%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Seven stateful components become TypeScript:
ProgressBar,ProgressStepsandCounter;Pagination,SelectandDropzone;StandaloneTabs.All seven are renamed with
git mv. Git detects every rename (61–75% similarity), so their history follows.The §9.3 step 6 hooks conversions among them are typed as they are:
props !== propsSeenderivations are untouched.ProgressBar.tsxProgressBarProps; the value may be a fraction or NaN, undefined or null, as documentedProgressSteps.tsxProgressStepsProps,ProgressStepCounter.tsxCounterProps,CounterRender, andCounterFramefor the exportednextFramePagination.tsxPaginationProps,PageChangeSelect.tsxSelectProps,SelectOptionDropzone.tsxDropzoneProps, andDropzoneHandle, the real handle withfileInputElincludedStandaloneTabs.tsxStandaloneTabsProps,StandaloneTab, andStandaloneTabsHandlefor function contentUpload's last component cast,Dropzone's, is deleted. ItsDropzoneHandleis re-exported fromDropzone.A throwaway probe of seven wrong call sites failed on all seven, and its correct counterparts compiled:
valueonProgressBar;step;Counterwithoutend;PaginationwithouttotalPages;Selectwithoutoptions;onDroptaking a string;content.What the checker surfaced
forwardRef's own type erases named props. It runs them throughOmit<…, 'ref'>, which keeps nothing but the index signature of a type that has one.RowRefhit the same trap in EPBDS-16211 E2: the leaf components the first batch still cast, as TypeScript #134.Dropzoneis therefore cast to the same component with its props kept.InputNative'sselectbranch handsSelectthe engineonChange,(value, name, event). That is the signatureSelectreports with.ForwardedPropssaid every branch overwrote the handler. The comment is corrected, and the call is a commented cast.StandaloneTabsrenders an object tab without aniconas it is. ItspropTypesaccept{text}alone, and React rejects rendering it. The component is demo-only, andNavTabspasses strings, so this is recorded and not fixed. The cast that keeps the JavaScript's assumption says so.renderFloatis still JavaScript, and its JSDoc types the element it returns asObject, soCounter's defaultrenderis cast.Counter'sclassNameandstyleare declared by itspropTypesand read by nothing. The type says so.No runtime change
Every edit is a type, a cast or a comment.
dist/index.jsshrank by 12 bytes, from 327,399 to 327,387, becauseUpload'sconst Dropzone = DropzoneJsalias is gone.Measured
translatecalls 1013, and 27 / 64 on an edit. The DOM is identical after mount and after an edit.src/core+src/libraryhold 64 TypeScript files, 9,989 lines (was 57 and 8,830), against 93 JavaScript files, 10,111 lines (was 100 and 11,051). That is 49.7% of the lines, up from 44.4%.Housekeeping
jest.config.js.Pagination.jsnow namePagination.tsx. One of them is in_semantic.lessand survives compilation, sopublic/static/ui-render.built.cssis rebuilt; it differs by that one line.docs/SUPPORTED-PROPS.mdneeded no change, asdocs:props:checkconfirms.docs/UPGRADE-PLAN.md§9.6-E2 has the note.Gates
All exited 0:
lint:js,lint:css,typecheck,typecheck:contract;docs:props:check,docs:views:check,css:fixture:check;test:env-flags,build;test:coverage, thresholds included. Every touched file's coverage is unchanged, and the partial ones (Pagination,StandaloneTabs,InputNative,Upload) are partial on the same expressions as on master;test:pack,test:pack:peers,test:types;test:react16,test:react19, 2908 tests each;test:e2e, 41 tests;test:react17took three runs, and none of them failed a test. Two runs lost a jest worker toSIGSEGV, the V8 crash of nodejs/node#62393 that this machine's Node 24.14 is known to hit:manifest.contract.test.js, and 2900 tests passed.Dropdown.gate.test.js, a file this PR does not touch, and 2901 tests passed.Both crashed suites also passed alone on the React 17 leg, 15 of 15. The three earlier React 17 runs this session, one per batch, were all clean.
In the demo on the dev server:
Pagination: a click on page 2 moved the current page and the table to rows 6 onwards.Upload: it rendered its threeDropzones, each with a hidden file input carrying the rightacceptandmultiple.StandaloneTabs: the navigation switched to "Styles", and one Back returned to the examples page, so there is one history entry per click.🤖 Generated with Claude Code