Skip to content

Wire up TypeScript tooling (build, type-check, types)#712

Open
pratik-londhe4 wants to merge 5 commits into
feat/fix-build-blocks-cssfrom
feat/typescript-config
Open

Wire up TypeScript tooling (build, type-check, types)#712
pratik-londhe4 wants to merge 5 commits into
feat/fix-build-blocks-cssfrom
feat/typescript-config

Conversation

@pratik-londhe4

@pratik-londhe4 pratik-londhe4 commented Jun 10, 2026

Copy link
Copy Markdown

Description

Sets up TypeScript tooling for the theme so components and scripts can be written in .ts/.tsx.

Technical Details

  • Build: @wordpress/scripts already transpiles .ts/.tsx on build/start (no webpack/babel changes needed). The one gap was the component build — getComponentEntries() matched /\.js$/, so .ts components were silently skipped; widened to /\.(jsx?|tsx?)$/. Scripts/styles under src/js/src/css already built .ts via readAllFileEntries (no extension filter).
  • Type-checking: added "lint:js:types": "tsc --noEmit" (wp-scripts does not type-check). Picked up by the lint:* aggregate.
  • Config: tsconfig.json — strict, allowJs: true, checkJs: false (so existing .js isn't force-checked mid-migration), noEmit, "@/*"./src/*, includes src/tests/the webpack+babel configs. src/global.d.ts declares *.scss / *.css module imports.
  • Deps: typescript, @types/react, @types/react-dom, @types/wordpress__block-editor, @types/jest (pinned exact via save-exact).
  • Linting: no @typescript-eslint/* added — they ERESOLVE-conflict with what @wordpress/eslint-plugin already bundles, and wp-scripts' lint-js lints TS through it.

Checklist

  • tsconfig.json + src/global.d.ts
  • tsc --noEmit type-check script (lint:js:types)
  • .ts/.tsx build via wp-scripts (verified a .ts entry compiles)
  • .ts/.tsx components build (component entry pattern fix; verified card.tscard.js)
  • tsc --noEmit catches real type errors (verified TS2345)

Screenshots

To-do

  • Migrate existing src JS → .ts/.tsx (separate effort); flip checkJs: true once done.
  • Mirror this setup in features-plugin-skeleton for parity.
  • Decide whether to converge the theme's context-dir entry scanning with the plugin's flat recursive scan.

Fixes/Covers issue

https://github.com/rtCamp/wp-framework/issues/44

@pratik-londhe4 pratik-londhe4 marked this pull request as ready for review June 10, 2026 20:16
@aryanjasala aryanjasala requested a review from Copilot June 11, 2026 05:58

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

This PR wires up TypeScript support for the theme so frontend scripts and components can be authored in .ts/.tsx, with build entry discovery updated accordingly and a dedicated tsc --noEmit type-check step added to the lint suite.

Changes:

  • Added strict TypeScript configuration (tsconfig.json) and global style-module declarations (src/global.d.ts) to support .scss/.css imports.
  • Updated the component webpack entry pattern to include .jsx/.ts/.tsx component scripts, and introduced initial .ts files/examples.
  • Added a lint:js:types script and pinned TypeScript + React/Jest type dependencies in package.json (with corresponding lockfile updates).

Reviewed changes

Copilot reviewed 3 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webpack.config.js Expands component script entry matching to include TS/TSX.
tsconfig.json Introduces strict TS config and path aliasing for @/*.
src/js/frontend/modules/media-text.ts Adds typed interactivity context and TS-friendly null-safety on ref.
src/js/frontend/core-navigation.ts Adds a TS entry importing the navigation SCSS.
src/global.d.ts Declares *.scss / *.css modules for TS imports.
src/components/button/button.ts Adds a starter TS component script entry.
package.json Adds type-check script and TS/React/Jest type devDependencies.
package-lock.json Locks the newly added tooling/type packages (and resulting dependency tree changes).

Comment thread package.json
Comment thread webpack.config.js
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