Skip to content

Enhancement Idea - Reduce number of generic parameters in models #78

Closed

Description

@oliverheywood451

This is a minor enhancement idea. If you look at models in the C# SDK, type parameters are handled slightly better (IMHO). OrderWorksheet is a good comparison because its so complex

	public class OrderWorksheet<TOrder, TLineItems, TOrderPromotions, TShipEstimateResponse, TOrderCalculateResponse, TOrderSubmitResponse, TOrderSubmitForApprovalResponse, TOrderApprovedResponse> : OrderWorksheet
		where TOrder : Order
		where TLineItems : LineItem
		where TOrderPromotions : OrderPromotion
		where TShipEstimateResponse : ShipEstimateResponse
		where TOrderCalculateResponse : OrderCalculateResponse
		where TOrderSubmitResponse : OrderSubmitResponse
		where TOrderSubmitForApprovalResponse : OrderSubmitForApprovalResponse
		where TOrderApprovedResponse : OrderApprovedResponse
	{
              ....
        }
export interface OrderWorksheet<TFromUserXp = any, TBillingAddressXp = any, TOrderXp = any, TProductXp = any, TVariantXp = any, TShippingAddressXp = any, TShipFromAddressXp = any, TLineItemsXp = any, TOrderPromotionsXp = any, TShipEstimatesXp = any, TShipEstimateResponseXp = any, TOrderCalculateResponseXp = any, TOrderSubmitResponseXp = any, TOrderSubmitForApprovalResponseXp = any, TOrderApprovedResponseXp = any> {
    Order?: Order<TOrderXp,TFromUserXp,TBillingAddressXp>
    LineItems?: LineItem<TLineItemsXp,TProductXp,TVariantXp,TShippingAddressXp,TShipFromAddressXp>[]
    OrderPromotions?: OrderPromotion<TOrderPromotionsXp>[]
    ShipEstimateResponse?: ShipEstimateResponse<TShipEstimateResponseXp,TShipEstimatesXp>
    OrderCalculateResponse?: OrderCalculateResponse<TOrderCalculateResponseXp>
    OrderSubmitResponse?: OrderSubmitResponse<TOrderSubmitResponseXp>
    OrderSubmitForApprovalResponse?: OrderSubmitForApprovalResponse<TOrderSubmitForApprovalResponseXp>
    OrderApprovedResponse?: OrderApprovedResponse<TOrderApprovedResponseXp>
}

In the C# sdk types are expected that extend the SDK models like Order and LineItem. In the JS sdk types are expected that hold the xp fields. This means there are more type arguments. The C# method is less verbose in the sdk code and in the client project code.

It also does require the creation of models like interface MyOrderPromotion extends OrderPromotion<MyOrderPromotionsXp> { }

Activity

  1. oliverheywood451 commented on Nov 4, 2022

    @oliverheywood451
    ContributorAuthor

    Thought of this because I saw there were breaking changes happening anyway ;)

  2. crhistianramirez commented on Nov 8, 2022

    @crhistianramirez
    Contributor

    @oliverheywood451 would be open to including this but honestly won't have any free time to dedicate to this for the next week or so. If you have bandwidth and are willing to add this functionality I will merge it in.

  3. linked a pull request that will close this issue#78 - Constrain nested model generics #153on Sep 28, 2026
  4. linked a pull request that will close this issue14.0.0 #152on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions