Skip to content

Commit

Permalink
fix: use more explicit unknown types
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Apr 10, 2024
1 parent bcb5b79 commit 6ce4ba5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/runtime/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface UseSanityQueryOptions<T> extends AsyncDataOptions<T> {
client?: string
}

export const useSanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, _options: UseSanityQueryOptions<T> = {}): AsyncData<T | null, E> => {
export const useSanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, unknown>, _options: UseSanityQueryOptions<T> = {}): AsyncData<T | null, E> => {
const { client, ...options } = _options
const sanity = useSanity(client)
const params = _params ? reactive(_params) : undefined
Expand All @@ -70,7 +70,7 @@ export const useSanityQuery = <T = unknown, E = Error> (query: string, _params?:
return useAsyncData('sanity-' + hash(query + (params ? JSON.stringify(params) : '')), () => sanity.fetch<T>(query, params || {}), options) as AsyncData<T | null, E>
}

export const useLazySanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, any>, _options: UseSanityQueryOptions<T> = {}): AsyncData<T | null, E> => {
export const useLazySanityQuery = <T = unknown, E = Error> (query: string, _params?: Record<string, unknown>, _options: UseSanityQueryOptions<T> = {}): AsyncData<T | null, E> => {
const { client, ...options } = _options
const sanity = useSanity(client)
const params = _params ? reactive(_params) : undefined
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* based on https://github.com/sanity-io/sanity/tree/next/packages/groq
*/
export const groq = String.raw || ((strings: TemplateStringsArray, ...keys: any[]) => {
export const groq = String.raw || ((strings: TemplateStringsArray, ...keys: string[]) => {
const lastIndex = strings.length - 1
return (
strings
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/minimal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SanityConfiguration extends ClientConfig {}

const enc = encodeURIComponent

export function getQuery (query: string, params: Record<string, any> = {}) {
export function getQuery (query: string, params: Record<string, unknown> = {}) {
const baseQs = `?query=${enc(query)}`
return Object.keys(params).reduce((current, param) => {
return `${current}&${enc(`$${param}`)}=${enc(
Expand Down Expand Up @@ -72,7 +72,7 @@ export function createClient (config: ClientConfig) {
/**
* Perform a fetch using GROQ syntax.
*/
async fetch<T = unknown> (query: string, params?: Record<string, any>) {
async fetch<T = unknown> (query: string, params?: Record<string, unknown>) {
const qs = getQuery(query, params)
const usePostRequest = getByteSize(qs) > 9000

Expand Down

0 comments on commit 6ce4ba5

Please sign in to comment.