chore: linting

This commit is contained in:
Max Leiter 2023-02-26 15:22:05 -08:00
parent 27a604dc90
commit a54a22f142
5 changed files with 14 additions and 13 deletions

View file

@ -18,17 +18,19 @@ export function Providers({ children }: PropsWithChildren<unknown>) {
) )
} }
export type ApiResponse<T> = { export type ApiResponse<T> =
| {
data: T data: T
error: never error: never
} | { }
| {
data: never data: never
error: string 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)

View file

@ -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({

View file

@ -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)
} }

View file

@ -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
View file

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