Skip to content

Conversation

@sethidden
Copy link
Contributor

@sethidden sethidden commented May 27, 2022

In Checkout.vue and Billing.vue there was a case where getSomeData() || {} was used. This was probably done to avoid worrying if something is null or not and avoiding the "x is null, trying to access property abc" error.

The problem with that is that it also causes problems with typing, as you'd get errors like "X is not assignable to {}"

@sethidden sethidden force-pushed the M2-643-use-null-instead-of-object-literal branch 2 times, most recently from 660eac9 to 1811c57 Compare May 27, 2022 10:42
@@ -0,0 +1,55 @@
import type { CustomerAddress, CartAddressInterface } from '~/modules/GraphQL/types';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(file was moved from address.js)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the file should be located in modules/checkout/helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just changing the extension :P

telephone: string;
}

export const getInitialCheckoutAddressForm = () : CheckoutAddressForm => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks to this, the {} can be avoided

@sethidden sethidden force-pushed the M2-643-use-null-instead-of-object-literal branch from 1811c57 to 7b5929e Compare May 27, 2022 10:51
@sethidden sethidden marked this pull request as ready for review May 27, 2022 10:54
export const getConfiguredVariant = (product: ConfigurableCartItem): ProductInterface | null => product?.configured_variant || null;

// eslint-disable-next-line import/no-named-as-default-member
export const getFormattedPrice = (price: number) => getFormattedPrice(price);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed weird self-referencing getter. it's not used anywhere

Frodigo
Frodigo previously approved these changes May 27, 2022
@@ -0,0 +1,55 @@
import type { CustomerAddress, CartAddressInterface } from '~/modules/GraphQL/types';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the file should be located in modules/checkout/helpers?

@sethidden sethidden force-pushed the M2-643-use-null-instead-of-object-literal branch from 7b5929e to 415ab27 Compare May 27, 2022 12:03
@sethidden sethidden merged commit 34c51f6 into develop May 27, 2022
@sethidden sethidden deleted the M2-643-use-null-instead-of-object-literal branch May 27, 2022 12:13
@Frodigo Frodigo added this to the 1.0.0-rc.9 milestone Jun 1, 2022
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.

3 participants