chore: linting

pull/141/head
Max Leiter 3 years ago
parent 27a604dc90
commit a54a22f142

@ -18,17 +18,19 @@ export function Providers({ children }: PropsWithChildren<unknown>) {
) )
} }
export type ApiResponse<T> = { export type ApiResponse<T> =
data: T | {
error: never data: T
} | { error: never
data: never }
error: string | {
} data: never
error: string
}
async function fetcher<T>(url: string): Promise<unknown> { async function fetcher<T>(url: string): Promise<unknown> {
const response = await fetch(url) const response = await fetch(url)
const data: ApiResponse<T> = await response.json() as ApiResponse<T> const data: ApiResponse<T> = (await response.json()) as ApiResponse<T>
if (data.error) { if (data.error) {
throw new Error(data.error) throw new Error(data.error)

@ -43,7 +43,7 @@ function VisibilityControl({
}) })
if (res.ok) { if (res.ok) {
const json = await res.json() as PostWithFiles const json = (await res.json()) as PostWithFiles
setVisibility(json.visibility) setVisibility(json.visibility)
router.refresh() router.refresh()
setToast({ setToast({

@ -59,7 +59,7 @@ const PostList = ({
} }
} }
) )
const json = await res.json() as PostWithFiles[] const json = (await res.json()) as PostWithFiles[]
setPosts(json) setPosts(json)
setSearching(false) setSearching(false)
} }

@ -36,7 +36,7 @@ export function useApiTokens({ userId, initialTokens }: UseApiTokens) {
} }
) )
const response = await res.json() as ApiResponse<SerializedApiToken> const response = (await res.json()) as ApiResponse<SerializedApiToken>
if (response.error) { if (response.error) {
throw new Error(response.error) throw new Error(response.error)
return return

3
types/index.d.ts vendored

@ -1,2 +1 @@
import "@total-typescript/ts-reset"
import "@total-typescript/ts-reset";

Loading…
Cancel
Save