Skip to content

Conversation

@OpenStaxClaude
Copy link
Contributor

@OpenStaxClaude OpenStaxClaude commented Nov 25, 2025

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-popup to TypeScript as part of the migration effort tracked in CORE-1386.

Changes

  • adoption-content.tsx: Added proper TypeScript types for cookie management, dismissal hooks, and component types
  • queue.tsx: Typed the microsurvey queue system with MicrosurveyComponent and UseContentHook types
  • sticky-content.tsx: Created StickyData type for sticky note content structure and typed all hook returns

Guidelines Followed

  • Avoided using any type
  • Preferred type over interface
  • Relied on type inference where possible
  • Used inline type definitions for function parameters
  • Kept line lengths under 120 characters
  • Each file ends with a blank line

Related Issue

https://openstax.atlassian.net/browse/CORE-1386

🤖 Generated with Claude Code

@RoyEJohnson RoyEJohnson marked this pull request as draft December 3, 2025 19:51
@RoyEJohnson RoyEJohnson force-pushed the port-layouts-to-ts branch 3 times, most recently from 178052b to 1c3c12a Compare December 16, 2025 21:06
@RoyEJohnson RoyEJohnson marked this pull request as ready for review December 16, 2025 21:11
@RoyEJohnson RoyEJohnson requested a review from jivey December 16, 2025 21:11
<div
className="right-bg clipped-image"
style={{backgroundImage: `url(${bannerImgUrl});`}}
style={{backgroundImage: `url(${bannerImgUrl})`}}
Copy link
Contributor

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.

Copy link
Member

@jivey jivey left a 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);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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.

OpenStaxClaude and others added 5 commits December 18, 2025 13:01
- 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
@RoyEJohnson RoyEJohnson merged commit 56cbbdb into main Dec 18, 2025
1 check passed
@RoyEJohnson RoyEJohnson deleted the port-layouts-to-ts branch December 18, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants