Skip to content

Chore: Centralize type definitions and lift search form logic#299

Merged
zigzagdev merged 16 commits intomainfrom
chore/remove-duplicate-types
Apr 29, 2026
Merged

Chore: Centralize type definitions and lift search form logic#299
zigzagdev merged 16 commits intomainfrom
chore/remove-duplicate-types

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

Summary

Consolidate duplicate type definitions across the codebase into
domain/types.ts and lift heritage search form logic into a dedicated container.

Changes

Type Centralization

  • Move Pagination, SearchValues into domain/types.ts
  • Remove duplicate UiPagination and replace with Pagination from domain
  • Drop unused ApiSearchResponse export
  • Import CriteriaCode from domain/types in CriteriaTags

Component Refactoring

  • Lift search form state and URL sync logic into SearchHeritageFormContainer
  • Remove draft state and submit handler from TopPageContainer
  • Inline anonymous prop types in heritage components

Code Quality

  • Rename single-character variables to descriptive names in search params mapper
  • Fix type guard direction: replace as casts with readonly string[] widening

zigzagdev and others added 15 commits April 29, 2026 12:32
Replace the named `type BaseCardProps = {...}` declaration with an
anonymous inline annotation on the component signature, in line with the
project rule that .tsx files should not host named type declarations.
Drop the named `Props` and `CheckboxRef` aliases in favor of placing the
ref element type and the `Omit<CheckboxProps, "ref"> & { label? }` shape
directly into the `React.forwardRef` generics, removing dead exports
that were not consumed elsewhere.
Remove the `export type Props = IconButtonProps` re-export, which was a
no-op alias not imported elsewhere, and reference `IconButtonProps`
directly in the `React.forwardRef` generic instead.
Drop the exported `Option<T>` and `Props<T>` declarations and write the
generic option/props shape directly on the function signature. The
exported aliases had no external consumers, so removing them keeps the
component self-contained.
Remove the named `Props` declaration and place the
`Omit<MUITextFieldProps, "multiline"> & { minRows?, maxRows? }` shape
directly into the `React.forwardRef` generic so the type stays scoped
to the component.
Remove the `export type Props = MUITextFieldProps` alias, which served
only as a renamed re-export with no external consumers, and reference
`MUITextFieldProps` directly in the `React.forwardRef` generic.
CriteriaTags was importing CriteriaCode from "../../domain/criteria",
but that module only re-imports the type from "./types.ts" without
re-exporting it, so the import resolved to nothing under the app
tsconfig (TS2724). Pull the type directly from "../../domain/types.ts"
where it is actually declared.
Replace the named `type Props = {...}` declaration with an anonymous
inline annotation on the component signature, matching the rule that
.tsx view files should not host named type declarations.
Move SearchValues to domain/types.ts and consolidate Pagination,
IdSortOption, and CriteriaCode usage so feature modules import a single
source of truth. Remove the duplicate SearchHeritagesApiResponse file
and the empty shared/api/http.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop named Props/HeritageCardProps/PaginationProps aliases and inline
the prop shape on each component signature, matching the in-progress
convention to keep .tsx files free of named type declarations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ainer

Move draft state, value sync, and submit handling out of TopPageContainer
into SearchHeritageFormContainer so the top page only owns paging/order
controls. Drop the onApiModeChange/redirect indirection that the new
container makes unnecessary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the unchecked DetailResponse<T>/ListResponse<T> generic casts
with isListResponse/isDetailResponse guards that throw on unexpected
shapes, so malformed payloads fail loudly instead of leaking into the
mappers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace single-letter parameter names (v/s/n/p/k) with descriptive ones
(value/trimmed/parsed/params/key) so parse and serialize helpers read
without decoding shorthand.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Translate Japanese comments to English in breadcrumb and pagination
  hook helpers.
- Widen region-count error state to unknown so non-Error rejections
  pass through unchanged.
- Inline the hook State type in useWorldHeritageDetail and tighten
  the AbortError detection helper.
- Drop the unused short_description_jp pass-through in the detail
  mapper and the unused breadcrumbMap export from shared/types/routes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Now that the search result container imports from domain/types, the
ApiSearchResponse alias is only consumed inside searchHeritages, so
remove the export to keep the surface narrow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zigzagdev zigzagdev self-assigned this Apr 29, 2026
@zigzagdev zigzagdev linked an issue Apr 29, 2026 that may be closed by this pull request
2 tasks
@zigzagdev zigzagdev linked an issue Apr 29, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zigzagdev zigzagdev merged commit aa248ea into main Apr 29, 2026
1 check passed
@zigzagdev zigzagdev deleted the chore/remove-duplicate-types branch April 29, 2026 07:23
@zigzagdev zigzagdev linked an issue May 3, 2026 that may be closed by this pull request
2 tasks
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.

Refactor: Remove duplicate types definition

1 participant