Fix type errors preventing build

This commit is contained in:
Filip Sodić 2023-04-07 18:59:35 +02:00
parent fdc1df8909
commit 4843cccd21
10 changed files with 31 additions and 23 deletions

View File

@ -1,6 +1,6 @@
app TodoApp {
wasp: {
version: "^0.8.0"
version: "^0.10.0"
},
title: "Todo app",

View File

@ -6,7 +6,7 @@ export async function login(data: { email: string; password: string }): Promise<
try {
const response = await api.post('{= loginPath =}', data);
await initSession(response.data.token);
} catch (e: unknown) {
} catch (e) {
handleApiError(e);
}
}

View File

@ -5,7 +5,7 @@ export async function requestPasswordReset(data: { email: string; }): Promise<{
try {
const response = await api.post('{= requestPasswordResetPath =}', data);
return response.data;
} catch (e: unknown) {
} catch (e) {
handleApiError(e);
}
}
@ -14,7 +14,7 @@ export async function resetPassword(data: { token: string; password: string; }):
try {
const response = await api.post('{= resetPasswordPath =}', data);
return response.data;
} catch (e: unknown) {
} catch (e) {
handleApiError(e);
}
}

View File

@ -5,7 +5,7 @@ export async function signup(data: { email: string; password: string }): Promise
try {
const response = await api.post('{= signupPath =}', data);
return response.data;
} catch (e: unknown) {
} catch (e) {
handleApiError(e);
}
}

View File

@ -1,11 +1,13 @@
{{={= =}=}}
import api, { handleApiError } from '../../../api';
import api, { handleApiError } from '../../../api'
export async function verifyEmail(data: { token: string; }): Promise<{ success: boolean; reason?: string; }> {
try {
const response = await api.post('{= verifyEmailPath =}', data);
return response.data;
} catch (e: unknown) {
handleApiError(e);
}
export async function verifyEmail(data: {
token: string
}): Promise<{ success: boolean; reason?: string }> {
try {
const response = await api.post('{= verifyEmailPath =}', data)
return response.data
} catch (e) {
handleApiError(e)
}
}

View File

@ -265,7 +265,7 @@ function Auth ({ state, appearance, logo, socialLayout = 'horizontal' }: {
// TODO(matija): this is called on every render, is it a problem?
// If we do it in useEffect(), then there is a glitch between the default color and the
// user provided one.
const customTheme = createTheme(appearance)
const customTheme = createTheme(appearance ?? {})
const cta = isLogin ? 'Log in' : 'Sign up'
const titles: Record<State, string> = {
@ -497,7 +497,7 @@ const VerifyEmailForm = ({ isLoading, setIsLoading, setErrorMessage, setSuccessM
const location = useLocation()
const token = new URLSearchParams(location.search).get('token')
const submitForm = useCallback(async () => {
async function submitForm() {
if (!token) {
setErrorMessage('The token is missing from the URL. Please check the link you received in your email.')
return
@ -513,7 +513,7 @@ const VerifyEmailForm = ({ isLoading, setIsLoading, setErrorMessage, setSuccessM
} finally {
setIsLoading(false)
}
})
}
useEffect(() => {
submitForm()

View File

@ -2,6 +2,7 @@
"extends": "@tsconfig/vite-react/tsconfig.json",
"compilerOptions": {
// Temporary loosen the type checking until we can address all the errors.
"jsx": "preserve",
"allowJs": true,
"strict": false
},

View File

@ -1,6 +1,6 @@
{{={= =}=}}
import { Application } from 'express'
import { type Application } from 'express'
import { Server } from 'http'
export type ServerSetupFn = (context: ServerSetupFnContext) => Promise<void>
@ -10,13 +10,13 @@ export type ServerSetupFnContext = {
server: Server,
}
export { Application } from 'express'
export type { Application } from 'express'
export { Server } from 'http'
{=# isExternalAuthEnabled =}
export { GetUserFieldsFn } from '../auth/providers/oauth/types';
export type { GetUserFieldsFn } from '../auth/providers/oauth/types';
{=/ isExternalAuthEnabled =}
{=# isEmailAuthEnabled =}
export { GetVerificationEmailContentFn, GetPasswordResetEmailContentFn } from '../auth/providers/email/types';
export type { GetVerificationEmailContentFn, GetPasswordResetEmailContentFn } from '../auth/providers/email/types';
{=/ isEmailAuthEnabled =}

View File

@ -34,7 +34,12 @@ test('handles mock data', async () => {
})
test('handles multiple mock data sources', async () => {
mockQuery(getMe, { id: 12, email: 'elon' })
mockQuery(getMe, {
id: 12, email: 'elon',
isEmailVerified: false,
emailVerificationSentAt: undefined,
passwordResetSentAt: undefined
})
mockQuery(getDate, new Date())
mockQuery(getTasks, mockTasks)

View File

@ -1,6 +1,6 @@
app todoApp {
wasp: {
version: "^0.9.1"
version: "^0.10.0"
},
title: "ToDo App",
// head: [],