Skip to content

[FEATURE]: Converts the package to typescript. - #127

Open
pravton wants to merge 14 commits into
mainfrom
feature/typescript-conversion
Open

[FEATURE]: Converts the package to typescript. #127
pravton wants to merge 14 commits into
mainfrom
feature/typescript-conversion

Conversation

@pravton

@pravton pravton commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Task: https://wethecollective.teamwork.com/app/tasks/25795363

Description.

Converts the package to TypeScript.

Additional notes

  • Andrew suggested trying the beta version, so pre.json is included with the changeset.
  • Updated the configs and packages.
  • Functionality is unchanged, and nothing should be breaking with this update.
  • Updated all components and the classnames util with types.
  • Updated the documentation with both JS and TS examples.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.ts output; adds a strict tsconfig.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

  • Root is 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
  • goToIndex currently treats falsy items (e.g., 0, "", false) as if the index is invalid because it checks !items[index]. Since items is 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]). If T can 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.

Comment thread .eslintrc
Comment on lines 8 to 12
"plugin:react-hooks/recommended",
"prettier"
"prettier",
],
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": "latest", "sourceType": "module" },
Comment thread package.json
Comment on lines +70 to 74
"@typescript-eslint/eslint-plugin": "^8.67.0",
"@typescript-eslint/parser": "^8.67.0",
"@vitejs/plugin-react-swc": "^4.3.3",
"eslint": "^8.5.7",
"eslint-config-prettier": "~9.1.0",
>
<Tag
className={buttonClassName}
aria-current={active ? "true" : null}
"@wethegit/react-gallery": minor
---

- Converts the package to typscript.
Comment thread README.md
- Accessibility. Built with careful attention to focus management and assistive technology.
- Fully-customizable layouts, using CSS Custom Properties.
- Provides a custom React hook for accessing gallery data, state, updater functions, and more. Build anything on top of the existing gallery components!
- Written in typescript
Comment thread .changeset/pre.json
Comment on lines +4 to +7
"initialVersions": {
"@wethegit/react-gallery": "5.0.0"
},
"changesets": []
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.

2 participants