-
Notifications
You must be signed in to change notification settings - Fork 5
Port src/app/layouts microsurvey-popup files from JS to TS #2800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1ba7e46 to
6ea6d9b
Compare
178052b to
1c3c12a
Compare
| <div | ||
| className="right-bg clipped-image" | ||
| style={{backgroundImage: `url(${bannerImgUrl});`}} | ||
| style={{backgroundImage: `url(${bannerImgUrl})`}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was yesterday's hotfix. I just rolled it into this PR rather than make a separate one.
jivey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some small type feedback, but the only blocker I see the queue test missing an assertion.
| const SEEN_ENOUGH = 3; | ||
|
|
||
| function StickyContent({stickyData, children}: {stickyData: StickyData | undefined; children: React.ReactNode}) { | ||
| const {body, link_url: url, link_text: text} = assertDefined(stickyData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, this assertion belongs in the caller (useBoundStickyContent?) because this component requires it to render, which is more clearly communicated by removing undefined from the type.
| render(<MemoryRouter initialEntries={['/']}> | ||
| <Component /> | ||
| </MemoryRouter>); | ||
| console.info('** Page', document.body.innerHTML); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't any assertions in this test?
| const QueuedItem = queue.length > 0 ? queue[0] : null; | ||
|
|
||
| useEnqueueWhenReady(useStickyMicrosurveyContent as UseContentHook, queue, setQueue); | ||
| useEnqueueWhenReady(useAdoptionMicrosurveyContent as UseContentHook, queue, setQueue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you but I think I'd prefer adding onDone to all the types to keep the shape consistent and avoid the cast.
- Convert adoption-content.js to TypeScript with proper return types - Convert queue.js to TypeScript with typed queue and component types - Convert sticky-content.js to TypeScript with StickyData type - Add React.ComponentType for microsurvey components - Type all hook parameters and return values - Add proper types for cookie reducer and dismissal logic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1. move assertDefined 2. add assertion to queue.test 3. Use QueuedItemType for adoption & sticky content
93c69dc to
83c0405
Compare
This may need to be redone, since #2799 removed sticky-footer, including some code in the microsurvey stuff. Wait until it is merged to pick this up.
Summary
Converts JavaScript files in
src/app/layouts/default/microsurvey-popupto TypeScript as part of the migration effort tracked in CORE-1386.Changes
Guidelines Followed
anytypetypeoverinterfaceRelated Issue
https://openstax.atlassian.net/browse/CORE-1386
🤖 Generated with Claude Code