Wire up TypeScript tooling (build, type-check, types)#712
Open
pratik-londhe4 wants to merge 5 commits into
Open
Wire up TypeScript tooling (build, type-check, types)#712pratik-londhe4 wants to merge 5 commits into
pratik-londhe4 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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/.cssimports. - Updated the component webpack entry pattern to include
.jsx/.ts/.tsxcomponent scripts, and introduced initial.tsfiles/examples. - Added a
lint:js:typesscript and pinned TypeScript + React/Jest type dependencies inpackage.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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Sets up TypeScript tooling for the theme so components and scripts can be written in
.ts/.tsx.Technical Details
@wordpress/scriptsalready transpiles.ts/.tsxonbuild/start(no webpack/babel changes needed). The one gap was the component build —getComponentEntries()matched/\.js$/, so.tscomponents were silently skipped; widened to/\.(jsx?|tsx?)$/. Scripts/styles undersrc/js/src/cssalready built.tsviareadAllFileEntries(no extension filter)."lint:js:types": "tsc --noEmit"(wp-scripts does not type-check). Picked up by thelint:*aggregate.tsconfig.json— strict,allowJs: true,checkJs: false(so existing.jsisn't force-checked mid-migration),noEmit,"@/*"→./src/*, includessrc/tests/the webpack+babel configs.src/global.d.tsdeclares*.scss/*.cssmodule imports.typescript,@types/react,@types/react-dom,@types/wordpress__block-editor,@types/jest(pinned exact viasave-exact).@typescript-eslint/*added — they ERESOLVE-conflict with what@wordpress/eslint-pluginalready bundles, and wp-scripts'lint-jslints TS through it.Checklist
tsconfig.json+src/global.d.tstsc --noEmittype-check script (lint:js:types).ts/.tsxbuild via wp-scripts (verified a.tsentry compiles).ts/.tsxcomponents build (component entry pattern fix; verifiedcard.ts→card.js)tsc --noEmitcatches real type errors (verified TS2345)Screenshots
To-do
srcJS →.ts/.tsx(separate effort); flipcheckJs: trueonce done.features-plugin-skeletonfor parity.Fixes/Covers issue
https://github.com/rtCamp/wp-framework/issues/44