Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Converts the @wethegit/react-gallery package source and build pipeline to TypeScript, adding type exports and updating docs/examples to support TS consumers while keeping runtime behavior largely the same.
Changes:
- Migrates library entry points, components, hooks, and utilities from JS/JSX to TS/TSX and adds shared type definitions.
- Updates Vite build to use a TS entry and generate
.d.tsoutput; adds a stricttsconfig.json. - Updates package metadata and README to publish/describe the new TypeScript typings and usage examples.
Reviewed changes
Copilot reviewed 21 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Adds vite-plugin-dts and switches lib entry to src/lib/index.ts. |
| tsconfig.json | Introduces strict TS compiler settings for the repo. |
| src/main.tsx | Updates example app to TS and adjusts React root initialization. |
| src/lib/utils/classnames.ts | Replaces JS utility with typed TS implementation. |
| src/lib/utils/classnames.js | Removes old JS classnames implementation. |
| src/lib/types/types.ts | Adds shared exported type definitions for components/hooks. |
| src/lib/types/css-modules.d.ts | Adds TS module declarations for CSS modules. |
| src/lib/index.ts | Adds typed public exports (components + types). |
| src/lib/index.js | Removes old JS index exports. |
| src/lib/hooks/use-gallery.tsx | Adds generic return typing for the useGallery hook. |
| src/lib/components/gallery-pagination.tsx | Migrates pagination component to TS with typed render props. |
| src/lib/components/gallery-pagination.jsx | Removes old JSX pagination component. |
| src/lib/components/gallery-pagination-item.tsx | Migrates pagination item to TS and adds click arg typing. |
| src/lib/components/gallery-pagination-item.jsx | Removes old JSX pagination item. |
| src/lib/components/gallery-nav.tsx | Migrates nav component to TS with typed render prop and props. |
| src/lib/components/gallery-main.tsx | Migrates main component to TS with generics and typed pointer events/styles. |
| src/lib/components/gallery-item.tsx | Migrates item component to TS with typed props and style casting. |
| src/lib/components/gallery-context.tsx | Migrates context/provider to TS with typed context value + props. |
| README.md | Adds JS + TS usage examples and updates type references in docs. |
| package.json | Adds types export and introduces TS-related dev tooling/scripts. |
| package-lock.json | Updates lockfile for new TS/dts/eslint dependencies and versioning. |
| .eslintrc | Adds TypeScript ESLint configuration. |
| .changeset/six-nails-tease.md | Adds changeset for the TypeScript conversion + docs updates. |
| .changeset/pre.json | Enables Changesets pre-release mode for a beta tag. |
Suppressed comments (6)
src/main.tsx:2
Rootis only used as a type; import it as type-only to avoid relying on tooling to erase it (and to prevent potential runtime named-import issues).
src/main.tsx:105- Typo in comment: "re-intializing" → "re-initializing".
src/lib/components/gallery-context.tsx:98 goToIndexcurrently treats falsy items (e.g.,0,"",false) as if the index is invalid because it checks!items[index]. Sinceitemsis generic (T[]), this should validate index bounds instead of item truthiness.
This issue also appears on line 114 of the same file.
src/lib/components/gallery-context.tsx:116
- This effect has the same falsy-item issue as
goToIndex(!items[activeIndex]). IfTcan be falsy, this may incorrectly reset the gallery. Prefer an index bounds check.
README.md:67 - Spelling/capitalization: "Javascript" should be "JavaScript".
#### Usage: Javascript
README.md:125
- Spelling/capitalization: "Typescript" should be "TypeScript".
#### Usage: Typescript
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "plugin:react-hooks/recommended", | ||
| "prettier" | ||
| "prettier", | ||
| ], | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, |
c85f334 to
970f952
Compare
saugatmalla
left a comment
There was a problem hiding this comment.
@pravton added some questions to you, let me know.
There was a problem hiding this comment.
🟡 Changes recommended
Multiple TypeScript, documentation, linting, metadata, and touch-handling issues remain unresolved.
11 open issues
.eslintrcis parsed as JSON; the trailing commas (e.g., after "prettier" and the last rule) make… Fix TypeScript capitalization in changeset text · New Fix JavaScript capitalization in heading · New Rename JSX example file from .ts to .tsx · New Export and import GalleryItemDataType in the example · New Rename JSX example file from .ts to .tsx · New Rename JSX example file from .ts to .tsx · New Import GalleryPaginationItemClickArgs in the TypeScript example · New Rename JSX example file from .ts to .tsx · New Support Gallery style prop or remove it from the example · New Include TypeScript files in the lint-staged matcher · New
2 resolved since last review
Review effort: Lite
| ```tsx | ||
| // your-gallery.ts | ||
|
|
||
| const handlePaginationItemClick = ({ event, index }: GalleryPaginationItemClickArgs) => { |
There was a problem hiding this comment.
Added the type-only import and brought GalleryItemDataType into scope in the example. Commit: fde8f2c.
|
|
||
| return ( | ||
| // Pass the style overrides to the <Gallery> component | ||
| <Gallery items={GALLERY_ITEMS} style={style}> |
There was a problem hiding this comment.
Added an optional CSSProperties style prop and forwarded it to Gallery’s root element while preserving its internal touch offset. Commit: 5894c2e.
| "build": "vite build", | ||
| "lint:scripts": "eslint --fix --ext .jsx,js --ignore-path .gitignore .", | ||
| "typecheck": "tsc --noEmit", | ||
| "lint:scripts": "eslint --fix --ext .tsx,ts --ignore-path .gitignore .", |
There was a problem hiding this comment.
Updated the lint-staged ESLint matcher to include .ts and .tsx in commit 1698f84.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>



Task: https://wethecollective.teamwork.com/app/tasks/25795363
Description.
Converts the package to TypeScript.
Additional notes
pre.jsonis included with the changeset.