feat: add TypeScript declarations for @juspay-tech/react-hyper-js#11
Open
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Open
feat: add TypeScript declarations for @juspay-tech/react-hyper-js#11ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Conversation
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
src/index.d.ts(435 lines) with complete TypeScript declarations for all exported components, hooks, and typessrc/index.test-d.ts, 370+ lines, 24 test categories) verified bytsc --noEmitpackage.jsonwithtypesandexportsfields for proper TypeScript resolutionChanges
Provider Components (3)
HyperElements— main SDK provider (acceptshyper: Promise<HyperInstance>)Elements— Stripe-compatible alias (acceptsstripeprop)HyperManagementElements— saved payment method management providerElement Components (12 + 5 aliases)
PaymentElement/UnifiedCheckoutCardElement/CardWidgetCardNumberElement/CardNumberWidgetCardExpiryElement/CardExpiryWidgetCardCVCElement/CardCVCWidgetExpressCheckoutElementPaymentMethodsManagementElementHooks (5)
useHyper()→UseHyperReturn(8 SDK methods + clientSecret)useWidgets()→UseWidgetsReturn(widget management)useElements()→ Stripe-compatible aliasuseHyperSession()→HyperSession(self-contained session)useHyperElements()→HyperElementsContextTypeTypes (12+)
UseHyperReturn,UseWidgetsReturn,HyperSession,SessionStatusHyperElementsProps,ElementsProps,PaymentElementComponentPropsPaymentElementSessionProps,HyperElementsContextTypePackage.json Updates
"types": "src/index.d.ts"field"exports"block with types conditiontypescriptand@juspay-tech/hyper-jsas devDependenciesArchitecture Decision: Bare Exports
Uses bare
exportstatements (NOTdeclare module "@juspay-tech/react-hyper-js") because:main: "dist/bundle.js"— TypeScript resolves viatypesfieldmoduleResolution: "bundler"and"node16"Testing
npx tsc --project tsconfig.test.json --noEmit # 0 errorsRelated PRs
juspay/hyperswitch-web— Demo app converted to TypeScript