feat: add complete TypeScript declarations for @juspay-tech/hyper-js#18
Open
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Open
feat: add complete TypeScript declarations for @juspay-tech/hyper-js#18ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
ArushKapoorJuspay wants to merge 2 commits intojuspay:mainfrom
Conversation
…pand HyperInstance with Click-to-Pay and headless methods - Fix EventData to match runtime (Types.res:5-17): replace focusTriggered/blurTriggered with focus/blur/ready/completeDoThis/confirmTriggered/oneClickConfirmTriggered - Remove incorrect Event/EventParam/EventHandler types (ReScript variant pattern not used at runtime) - Add EventName literal union for type-safe event subscription - Add ComponentType literal union for type-safe element creation - Fix PaymentElement.on() signature to match runtime callback (EventData | undefined) - Add PaymentElement.onSDKHandleClick() method - Fix Element interface: use ComponentType, ElementsUpdateOptions, optional options param - Add Click-to-Pay supporting types and session interfaces - Add HyperInstance methods: confirmOneClickPayment, initPaymentSession, initAuthenticationSession, paymentMethodsManagementElements, completeUpdateIntent, initiateUpdateIntent, confirmTokenization - Expand LoadOptions with isPreloadEnabled, isTestMode, isForceInit, redirectionFlags, analytics
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(1098 → 1205 lines) to match the runtime API surface fromhyperswitch-web/src/hyper-loader/Hyper.ressrc/index.test-d.ts, 556 lines, 42 test functions) verified bytsc --noEmitChanges
EventData (fixed)
focusTriggered/blurTriggered) with runtime-correctfocus/blurhyperswitch-web/src/hyper-loader/Types.res:5-17exactly (11 fields)New Types Added
EventName— 9-value string literal union for all SDK eventsComponentType— 14-value union for all creatable element types (card, payment, googlePay, applePay, klarna, paze, samsungPay, etc.)HyperInstance (expanded)
Added 7 methods missing from the original declarations:
confirmOneClickPayment— one-click saved card confirmationinitPaymentSession/initAuthenticationSession— Click-to-Pay session lifecyclepaymentMethodsManagementElements— saved payment method managementcompleteUpdateIntent/initiateUpdateIntent— update intent flowsconfirmTokenization— tokenization confirmationPaymentElement (expanded)
onSDKHandleClickmethod for intercepting pay button clicksSupporting Interfaces
ClickToPaySession,BrowserInfo,ConfirmOneClickPaymentParams,ConfirmTokenizationParams, etc.LoadOptionswithcustomBackendUrl,customLogUrl,customLoggingEndpointType Tests
tsc --noEmit(0 errors)Source of Truth
The declarations match the runtime API from
hyperswitch-web/src/hyper-loader/Hyper.res:804-818(13 methods), NOT the outdatedhyper-js/src/Types.res(9 methods).hyper-jsis a thin script loader that passes through the object created by hyperswitch-web.Testing
npx tsc --project tsconfig.test.json --noEmit # 0 errorsRelated PRs
juspay/react-hyper-js— TypeScript declarations for React wrapperjuspay/hyperswitch-web— Demo app converted to TypeScript