Skip to content

fix(types): outdated error message #608

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

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export type CheckMatchingArrayTypes<Result, NewResult> =
Result,
NewResult,
{
Error: 'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object'
Error: 'Type mismatch: Cannot cast array result to a single object. Use .overrideTypes<Array<YourType>> or .returns<Array<YourType>> (deprecated) for array results or .single() to convert the result to a single object'
},
{
Error: 'Type mismatch: Cannot cast single object to array type. Remove Array wrapper from return type or make sure you are not using .single() up in the calling chain'
Expand Down
2 changes: 1 addition & 1 deletion test/override-types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
TypeEqual<
typeof result,
{
Error: 'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object'
Error: 'Type mismatch: Cannot cast array result to a single object. Use .overrideTypes<Array<YourType>> or .returns<Array<YourType>> (deprecated) for array results or .single() to convert the result to a single object'
}
>
>(true)
Expand Down
2 changes: 1 addition & 1 deletion test/returns.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
}
let resultType: typeof invalidCastArray.data
let resultExpected: {
Error: 'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object'
Error: 'Type mismatch: Cannot cast array result to a single object. Use .overrideTypes<Array<YourType>> or .returns<Array<YourType>> (deprecated) for array results or .single() to convert the result to a single object'
}
expectType<TypeEqual<typeof resultType, typeof resultExpected>>(true)

Expand Down
Loading