Skip to content

Commit

Permalink
fix flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherChudzicki committed Jan 8, 2024
1 parent 7c6e4e5 commit b762872
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 25 deletions.
3 changes: 2 additions & 1 deletion frontend/public/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"rules": {
"no-unused-vars": [
"error", {
"argsIgnorePattern": "^__"
"argsIgnorePattern": "^__",
"ignoreRestSiblings": true
}
],
// module importing pattern have huge impact over performance, especially when it comes to lodash
Expand Down
3 changes: 3 additions & 0 deletions frontend/public/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
[libs]
./src/flow/declarations.js

[declarations]
.*/node_modules/redux-query/.*

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
Expand Down
7 changes: 5 additions & 2 deletions frontend/public/src/containers/pages/login/LoginEmailPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ import EmailForm from "../../../components/forms/EmailForm"

import type { RouterHistory, Location } from "react-router"

import type { QueryResponse } from "redux-query/types.js.flow"
import type { HttpResponse } from "../../../flow/httpTypes"
import type { AuthResponse, EmailFormValues } from "../../../flow/authTypes"
import { Link } from "react-router-dom"

type Props = {
location: Location,
history: RouterHistory,
loginEmail: (email: string, next: ?string) => Promise<QueryResponse<AuthResponse>>
loginEmail: (
email: string,
next: ?string
) => Promise<HttpResponse<AuthResponse>>
}

export class LoginEmailPage extends React.Component<Props> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { STATE_ERROR, handleAuthResponse } from "../../../lib/auth"
import LoginPasswordForm from "../../../components/forms/LoginPasswordForm"

import type { RouterHistory, Location } from "react-router"
import type { Response } from "redux-query"
import type {
AuthResponse,
User,
PasswordFormValues
} from "../../../flow/authTypes"
import type { HttpResponse } from "../../../flow/httpTypes"

type Props = {
location: Location,
Expand All @@ -30,8 +30,8 @@ type Props = {
loginPassword: (
password: string,
partialToken: string
) => Promise<Response<AuthResponse>>,
getCurrentUser: () => Promise<Response<User>>
) => Promise<HttpResponse<AuthResponse>>,
getCurrentUser: () => Promise<HttpResponse<User>>
}

export class LoginPasswordPage extends React.Component<Props> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import users, { currentUserSelector } from "../../../lib/queries/users"
import queries from "../../../lib/queries"
import EditProfileForm from "../../../components/forms/EditProfileForm"

import type { Response } from "redux-query"
import type { HttpResponse } from "../../../flow/httpTypes"
import type { Country, User } from "../../../flow/authTypes"
import type { RouterHistory } from "react-router"

Expand All @@ -23,8 +23,8 @@ type StateProps = {|
|}

type DispatchProps = {|
editProfile: (userProfileData: User) => Promise<Response<User>>,
getCurrentUser: () => Promise<Response<User>>
editProfile: (userProfileData: User) => Promise<HttpResponse<User>>,
getCurrentUser: () => Promise<HttpResponse<User>>
|}

type ProfileProps = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
AddlProfileFields
} from "../../../components/forms/ProfileFormFields"

import type { Response } from "redux-query"
import type { HttpResponse } from "../../../flow/httpTypes"
import type { User } from "../../../flow/authTypes"
import { addUserNotification } from "../../../actions"

Expand All @@ -28,8 +28,8 @@ type StateProps = {|
|}

type DispatchProps = {|
editProfile: (userProfileData: User) => Promise<Response<User>>,
getCurrentUser: () => Promise<Response<User>>
editProfile: (userProfileData: User) => Promise<HttpResponse<User>>,
getCurrentUser: () => Promise<HttpResponse<User>>
|}

type Props = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ const mapStateToProps = createStructuredSelector({
qsParams: qsSelector
})

const mapPropsToConfig = ({ qsParams }) =>
mutateAsync(queries.auth.registerConfirmEmailMutation(qsParams))
const mapPropsToConfig = ({ qsParams }) => {
const { type, ...config } = mutateAsync(
queries.auth.registerConfirmEmailMutation(qsParams)
)
return config
}

const mapDispatchToProps = {
addUserNotification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import RegisterDetailsForm from "../../../components/forms/RegisterDetailsForm"
import { addUserNotification } from "../../../actions"

import type { RouterHistory, Location } from "react-router"
import type { Response } from "redux-query"
import type { HttpResponse } from "../../../flow/httpTypes"
import type {
AuthResponse,
LegalAddress,
Expand Down Expand Up @@ -57,8 +57,8 @@ type DispatchProps = {|
userProfile: UserProfile,
partialToken: string,
next: ?string
) => Promise<Response<AuthResponse>>,
getCurrentUser: () => Promise<Response<User>>,
) => Promise<HttpResponse<AuthResponse>>,
getCurrentUser: () => Promise<HttpResponse<User>>,
addUserNotification: Function
|}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import RegisterEmailForm from "../../../components/forms/RegisterEmailForm"
import { routes } from "../../../lib/urls"

import type { RouterHistory, Location } from "react-router"
import type { Response } from "redux-query"
import type { HttpResponse } from "../../../flow/httpTypes"
import type { AuthResponse } from "../../../flow/authTypes"
import type { RegisterEmailFormValues } from "../../../components/forms/RegisterEmailForm"

Expand All @@ -39,7 +39,7 @@ type Props = {
email: string,
recaptcha: ?string,
next: ?string
) => Promise<Response<AuthResponse>>,
) => Promise<HttpResponse<AuthResponse>>,
addUserNotification: Function
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { qsVerificationCodeSelector } from "../../../lib/selectors"
import type { RouterHistory, Location } from "react-router"
import type { updateEmailResponse } from "../../../flow/authTypes"
import users from "../../../lib/queries/users"
import type { QueryResponse } from "redux-query/types.js.flow"
import type { HttpResponse } from "../../../flow/httpTypes"
import type { User } from "../../../flow/authTypes"

type Props = {
Expand All @@ -31,7 +31,7 @@ type Props = {
location: Location,
history: RouterHistory,
updateEmail: ?updateEmailResponse,
getCurrentUser: () => Promise<QueryResponse<User>>
getCurrentUser: () => Promise<HttpResponse<User>>
}

export class EmailConfirmPage extends React.Component<Props> {
Expand Down Expand Up @@ -118,8 +118,10 @@ const getCurrentUser = () =>
const confirmEmail = (code: string) =>
mutateAsync(queries.auth.confirmEmailMutation(code))

const mapPropsToConfig = ({ params: { verificationCode } }) =>
confirmEmail(verificationCode)
const mapPropsToConfig = ({ params: { verificationCode } }) => {
const { type, ...others } = confirmEmail(verificationCode)
return others
}

const mapDispatchToProps = {
addUserNotification,
Expand Down
4 changes: 2 additions & 2 deletions frontend/public/src/lib/queries/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const updateEmailSelector = pathOr(null, ["entities", "updateEmail"])
const nextState = nthArg(1)

const DEFAULT_OPTIONS = {
transform: (auth: AuthResponse) => ({ auth }),
transform: (auth: ?AuthResponse) => ({ auth }),
update: {
auth: nextState
},
Expand Down Expand Up @@ -154,7 +154,7 @@ export default {
confirmEmailMutation: (code: string) => ({
queryKey: "updateEmail",
url: `/api/change-emails/${code}/`,
transform: (json: updateEmailResponse) => ({
transform: (json: ?updateEmailResponse) => ({
updateEmail: json
}),
update: {
Expand Down

0 comments on commit b762872

Please sign in to comment.