Fix TS errors

This commit is contained in:
Andrew Kingston 2024-12-05 16:44:56 +00:00
parent 5c08b6d962
commit e44ce7ee62
No known key found for this signature in database
4 changed files with 6 additions and 8 deletions

View File

@ -30,7 +30,7 @@ export const buildAnalyticsEndpoints = (
...request,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
},
parseResponse: () => null,
parseResponse: () => undefined,
})
},
})

View File

@ -1,11 +1,11 @@
import { Flags, SetFlagRequest } from "@budibase/types"
import { Flags, SetUserFlagRequest, SetUserFlagResponse } from "@budibase/types"
import { BaseAPIClient } from "./types"
export interface FlagEndpoints {
getFlags: () => Promise<Flags>
// Missing request or response types
updateFlag: (flag: string, value: any) => Promise<{ message: string }>
updateFlag: (flag: string, value: any) => Promise<SetUserFlagResponse>
toggleUiFeature: (value: string) => Promise<{ message: string }>
}
@ -25,7 +25,7 @@ export const buildFlagEndpoints = (API: BaseAPIClient): FlagEndpoints => ({
* @param value the value to set the flag to
*/
updateFlag: async (flag, value) => {
return await API.post<SetFlagRequest, { message: string }>({
return await API.post<SetUserFlagRequest, SetUserFlagResponse>({
url: "/api/users/flags",
body: {
flag,

View File

@ -160,10 +160,8 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
try {
if (parseResponse) {
return await parseResponse(response)
} else if (response.status !== 204) {
return (await response.json()) as ResponseT
} else {
return undefined
return (await response.json()) as ResponseT
}
} catch (error) {
delete cache[url]

View File

@ -84,7 +84,7 @@ export const buildLicensingEndpoints = (
refreshLicense: async () => {
return API.post({
url: "/api/global/license/refresh",
parseResponse: () => null,
parseResponse: () => undefined,
})
},
/**