Skip to content

Loss of params and query Types Due to Generics in OptionsType #2

@IRaccoonI

Description

@IRaccoonI

There is an issue with the OptionsType where the types for params and query may be lost due to the usage of generics. This problem affects the ability to correctly type-check path and query parameters, leading to potential runtime errors and difficulties in maintaining type safety.

Affected Code:

export type OptionsType<
  Schema extends SchemaType,
  Method extends MethodType,
  Route extends RoutesForMethod<Schema, Method>,
  Status extends ValidStatusType | undefined = undefined,
> = MakeNeverEmpty<{
  params: RoutePath<Schema, Method, Route>;
  query: RouteQuery<Schema, Method, Route>;
}> & {
  axios?: AxiosRequestConfig;
  validStatus?: Status;
  querySerializationParams?: QuerySerializationParams;
};

Problem:

The usage of generics in the OptionsType definition may result in the loss of type information for params and query, which are essential for proper request handling. This issue needs to be addressed to ensure that type safety is maintained throughout the codebase.

Task:

  • Investigate the root cause of the type loss.
  • Refactor the generics or adjust the type definitions to prevent the loss of params and query types.
  • Validate that the solution preserves type safety and improves overall type correctness.

This issue is crucial for maintaining robust type definitions and preventing potential bugs that may arise from incorrectly typed parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions