New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkout: Convert CompositeCheckout component to TypeScript #46758
Checkout: Convert CompositeCheckout component to TypeScript #46758
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~46 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~628 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~878 bytes removed 📉 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
02dd334
to
10ac19e
Compare
fd4c9bb
to
0d9325a
Compare
8bed690
to
783d5c1
Compare
242bc6a
to
ad20fe0
Compare
I see some odd behavior when renewing a plan; it also happens on master so is not related to this PR. Reported at https://github.com/Automattic/payments-shilling/issues/37 |
Yeah, good find. We'll need to modify the |
I tried a bunch of flows and didn't see any behavioral bugs. This is not exhaustive, but as you say, exhaustive testing would take a long time and if this does break something it should be clear quickly.
I checked for a "THANK_YOU_URL_GENERATED" event, and it looks normal: I did see a couple of relevant looking console errors while navigating around checkout, but they did not cause any visible problems or prevent checkout from completing: (Don't think these are related to each other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and works as described!
32302b5
to
9a281c6
Compare
There are several reasons why useRedirectIfCartEmpty should be disabled, and we keep adding more. Rather than passing all of those values into the hook and making it know how to deal with each one, this puts that responsibility on the caller by replacing them with a single boolean arugment called `doNotRedirect`.
When originally typing the WPCOM payment method strings, we were still learning TypeScript and we created object types for each one as `WPCOMPaymentMethodClass`. However, we need to know the string values in some places, and so this simplifies `WPCOMPaymentMethodClass` by creating a separate type for that string.
I believe that this was a mistake when the type was created. In use, it appears to actually be an object.
Both of these types are objects, not arrays. I believe this was a mistake when these types were created, possibly because when these properties are returned empty, they are an empty array due to PHP's syntax.
They were already missing.
This will make it easier to locate dependencies outside of composite-checkout as we try to reduce those dependencies.
The reducer always returns at least an object.
ad20fe0
to
f7e9620
Compare
Rebased after #46671 |
Changes proposed in this Pull Request
This converts the main component in new checkout,
CompositeCheckout
, to TypeScript. In the process, it fixes several small bugs and type errors.Testing instructions
This touches nearly all aspects of checkout, but it's impossible to test them all, and like many other recent refactors, if anything serious is broken by this, it should be obvious quickly.
Notable changes:
arguments
has been removed from theTHANK_YOU_URL_GENERATED
analytics event. They have actually been missing since Checkout: Convert getThankYouUrl to TypeScript #46423. It would be nice to add them back in, but getting them out of the hook is actually non-trivial and I'd rather that be in its own PR. For the moment, this just removes the unused property. This should have no effect, but it might be worth examining the event when it runs to be sure it's working.doesValueExist
to a top-level helper in the composite checkout directory which can be used as[].filter(doesValueExist)
in place of[].filter(Boolean)
to please TypeScript. This should have no user-facing effect as long as it filters out falsy values correctly. If it doesn't, we'd probably see lots of errors about adding products when no product add errors exist.useRedirectIfCartEmpty
more explicit about when it will and won't redirect; there's now a single argument,doNotRedirect
, which is used for that decision, putting the logic fully in the consumer. Worth testing that we are still redirected when we'd expect to be, and are not redirected if the cart is empty and an invalid product slug is in the URL.