-
-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The test at line 198-199 has a commented-out type assertion for the error value when using conditional queries with the SKIP token and select option.
Location
packages/openapi-vue-query/test/index.test.tsx:198-199
expectTypeOf(result.data.value).toEqualTypeOf<"select(true)" | undefined>();
// TODO: fix this
// expectTypeOf(result.error.value).toEqualTypeOf<false | null>();Problem Analysis
- When using
SKIPtoken withselectoption, the error type inference doesn't work as expected - Expected type:
false | null(matching the error type from the OpenAPI schema) - Actual type: Likely
unknown | nullor a different inferred type - This suggests that the
UseQueryMethodtype definition doesn't properly preserve error types whenselectis used
Context
The test creates a conditional query:
const { result } = renderHook(() =>
useQuery(
false
? {
...client.queryOptions("get", "/foo"),
select: (data) => {
expectTypeOf(data).toEqualTypeOf<true>();
return "select(true)" as const;
},
}
: SKIP,
),
);Proposed Solutions
-
Review
UseQueryMethoderror type parameter:- Ensure error type is properly preserved when
selectis used - Check if
InferSelectReturnTypeaffects error type inference
- Ensure error type is properly preserved when
-
Fix error type in return type:
- The
UseQueryMethodreturn type (lines 94-123) should properly include the error type - Ensure it's not being overridden or lost in type transformations
- The
-
Update type definition structure:
- Consider if
Response["error"]is properly passed through all type transformations - Check interaction between
DeepUnwrapRefand error types
- Consider if
-
Alternative: Update test expectations:
- If the current behavior is actually correct, update the test to match
- Document why the error type differs from the schema type (last resort)
Acceptance Criteria
- Uncomment the error type assertion line
- Type test passes with expected error type
false | null - Error type inference works correctly in real-world usage
- All existing tests pass
Additional Context
This issue is related to TypeScript type compatibility between openapi-fetch response types, @tanstack/vue-query hook signatures, and Vue 3 reactivity types.
Current dependencies:
@tanstack/vue-query: ^5.66.0openapi-fetch: ^0.14.0vue: ^3.5.13
These issues likely emerged from recent updates to @tanstack/vue-query (see PR #59 which fixed some type compatibility issues but may have introduced these).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working