feat(demo-app): convert Hyperswitch-React-Demo-App to TypeScript#1485
Open
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Open
feat(demo-app): convert Hyperswitch-React-Demo-App to TypeScript#1485ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Conversation
- Rename all 7 source files from .js to .tsx/.ts - Add tsconfig.json with strict mode and moduleResolution: bundler - Add globals.d.ts for webpack DefinePlugin globals and asset modules - Add local ambient type declarations for @juspay-tech/hyper-js and @juspay-tech/react-hyper-js (subset used by demo app) - Update webpack.common.js: add @babel/preset-typescript, .ts/.tsx extensions - Add proper type annotations: component props, state, event handlers, async function signatures, CartItem interface - All 0 tsc --noEmit errors with strict mode enabled
Changed Files
|
…Instance, remove index signatures, add TODO for temporary ambient declarations
db50539 to
81f05fb
Compare
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.
Summary
Converts all 7 JavaScript source files in
Hyperswitch-React-Demo-App/to TypeScript with strict mode enabled and 0 type errors.Changes
Config Files (created)
tsconfig.json— strict mode,moduleResolution: "bundler",jsx: "react-jsx"src/globals.d.ts— webpack DefinePlugin globals (ENDPOINT,SCRIPT_SRC,SELF_SERVER_URL,SDK_VERSION),Window.Hyperaugmentation, asset module declarations, local ambient type declarations for@juspay-tech/hyper-jsand@juspay-tech/react-hyper-jsBuild Tooling (modified)
webpack.common.js— added@babel/preset-typescriptto babel presets,.ts/.tsxto resolve extensions, updated entry fromindex.jstoindex.tsxpackage.json— addedtypescript,@types/react,@types/react-dom,@babel/preset-typescriptto devDependenciesSource Files (renamed + typed)
index.jsindex.tsxgetElementByIdApp.jsApp.tsxPayment.jsPayment.tsxPromise<HyperInstance> | nullstate,string | nullerrorCheckoutForm.jsCheckoutForm.tsxReact.FormEvent<HTMLFormElement>, typed catch clauseCompletion.jsCompletion.tsxCart.jsCart.tsxCartIteminterfaceutils.jsutils.tsReact.Dispatchtypes,PaymentStatusMessagesWhy Local Ambient Declarations?
The demo app's
node_modulescontains the published@juspay-tech/hyper-jsand@juspay-tech/react-hyper-jspackages which don't havetypesfields yet. Local ambient declarations inglobals.d.tsprovide the type subset used by the demo app. Once the companion PRs ship, these can be removed in favor of the real.d.tsfiles.Testing
Related PRs
@juspay-tech/hyper-js@juspay-tech/react-hyper-js