Skip to content

Create a package for "Klarna Checkout API - clientside events"#103

Draft
adamsoderstrom wants to merge 2 commits intomainfrom
klarna-checkout-types
Draft

Create a package for "Klarna Checkout API - clientside events"#103
adamsoderstrom wants to merge 2 commits intomainfrom
klarna-checkout-types

Conversation

@adamsoderstrom
Copy link
Member

In attempt to have complete TS coverage in a project, you'd need to type external dependencies.
This PR covers one of these scenarios.

This PR provides a package, containing the type definition of the window._klarnaCheckout function.

The PR is interpreted from the documentation of the Klarna Checkout > In-depth Knowledge > Client-side events.

By consuming this package, you be able to get type definitions on the callbacks from your _klarnaCheckout function:

Before

      // eslint-disable-next-line no-underscore-dangle
      window._klarnaCheckout((api) => {
        api.on({ // `on` does not exist on type `any`
          shipping_option_change: (shippingInfo) => { // Where `shippingInfo` is now of type `any`
          },
        })
      })

After

      // eslint-disable-next-line no-underscore-dangle
      window._klarnaCheckout((api) => {
        api.on({ // exists
          shipping_option_change: (shippingInfo) => { // Where `shippingInfo` is now of type `Klarna.ShippingOptionChangeEvent`
          },
        })
      })

@vercel
Copy link

vercel bot commented May 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
centra-types-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2023 4:23pm
react-centra-checkout-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2023 4:23pm

Comment on lines +17 to +27
## Usage

```typescript
import type { Klarna } from '@noaignite/klarna-checkout-types'

declare global {
interface Window {
_klarnaCheckout?: (callback: Klarna.CheckoutCallback) => void
}
}
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be done inside the actual package..? 🤔

@vercel vercel bot temporarily deployed to Preview – react-centra-checkout-docs May 4, 2023 16:23 Inactive
@vercel vercel bot temporarily deployed to Preview – centra-types-docs May 4, 2023 16:23 Inactive
@adamsoderstrom
Copy link
Member Author

adamsoderstrom commented May 8, 2023

Would be great if i could get some assistance on publishing + review! 💞
@alexanderflink
@maeertin

@maeertin
Copy link
Contributor

maeertin commented Aug 12, 2024

question: Is this still relevant? If so, I guess we'd want to rebase against the new main branch :)

Going through PRs now that we're up and running again with our internal packages.

@adamsoderstrom

@@ -0,0 +1,28 @@
# @noaignite/centra-types
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: change to @noaignite/klarna-checkout-types

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This package should not be used in Centra projects. Add that to the README.md

@adamsoderstrom
Copy link
Member Author

todo: Verify that these types are up-do-date.

@maeertin maeertin marked this pull request as draft October 23, 2024 12:01
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.

4 participants