chore: linting
This commit is contained in:
parent
27a604dc90
commit
a54a22f142
5 changed files with 14 additions and 13 deletions
|
@ -18,17 +18,19 @@ export function Providers({ children }: PropsWithChildren<unknown>) {
|
|||
)
|
||||
}
|
||||
|
||||
export type ApiResponse<T> = {
|
||||
data: T
|
||||
error: never
|
||||
} | {
|
||||
data: never
|
||||
error: string
|
||||
}
|
||||
export type ApiResponse<T> =
|
||||
| {
|
||||
data: T
|
||||
error: never
|
||||
}
|
||||
| {
|
||||
data: never
|
||||
error: string
|
||||
}
|
||||
|
||||
async function fetcher<T>(url: string): Promise<unknown> {
|
||||
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) {
|
||||
throw new Error(data.error)
|
||||
|
|
|
@ -43,7 +43,7 @@ function VisibilityControl({
|
|||
})
|
||||
|
||||
if (res.ok) {
|
||||
const json = await res.json() as PostWithFiles
|
||||
const json = (await res.json()) as PostWithFiles
|
||||
setVisibility(json.visibility)
|
||||
router.refresh()
|
||||
setToast({
|
||||
|
|
|
@ -59,7 +59,7 @@ const PostList = ({
|
|||
}
|
||||
}
|
||||
)
|
||||
const json = await res.json() as PostWithFiles[]
|
||||
const json = (await res.json()) as PostWithFiles[]
|
||||
setPosts(json)
|
||||
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) {
|
||||
throw new Error(response.error)
|
||||
return
|
||||
|
|
3
types/index.d.ts
vendored
3
types/index.d.ts
vendored
|
@ -1,2 +1 @@
|
|||
|
||||
import "@total-typescript/ts-reset";
|
||||
import "@total-typescript/ts-reset"
|
||||
|
|
Loading…
Reference in a new issue