Skip to content

Commit 386f6e3

Browse files
authored
feat: type fixes (#89)
* fix: exports * fix dependencies * missing exports * use workspace * test * branch * fix * prettier ignore * toEqual * type JSX * ignore src/scripts/* * fix proxy * simplify * fix * fix * fix * fix * fix * fix * remove irrelevant paths
1 parent b6a97fb commit 386f6e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+500
-419
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
paths-ignore:
66
- '**/*.md'
7-
- '**/*.code-*'
8-
- '.vscode/**'
9-
- '.devcontainer.json'
107
pull_request:
118
issues:
129
issue_comment:

eslint.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import ts from "typescript-eslint"
33

44
export default ts.config(
55
...workspaceConfig,
6-
{ ignores: ["src/scripts/*"] },
6+
{
7+
ignores: [
8+
"src/scripts/*",
9+
"src/server.js", // TODO: convert to src/server.ts and remove this ignore
10+
],
11+
},
712
{
813
languageOptions: {
914
parserOptions: { tsconfigRootDir: import.meta.dirname },

src/api/createApi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
2+
type FetchArgs,
23
createApi as _createApi,
34
fetchBaseQuery,
4-
type FetchArgs,
55
} from "@reduxjs/toolkit/query/react"
66

77
import { SERVICE_API_URL } from "../settings"
8-
import defaultTagTypes from "./tagTypes"
98
import { buildLogoutEndpoint } from "./endpoints/session"
9+
import defaultTagTypes from "./tagTypes"
1010
import { getCsrfCookie } from "../utils/auth"
1111
import { isSafeHttpMethod } from "../utils/api"
1212

@@ -45,7 +45,7 @@ export default function createApi<TagTypes extends string = never>({
4545
const method = typeof arg === "string" ? "GET" : arg.method || "GET"
4646

4747
if (type === "mutation" || !isSafeHttpMethod(method)) {
48-
let csrfToken = getCsrfCookie()
48+
const csrfToken = getCsrfCookie()
4949
if (csrfToken) headers.set("x-csrftoken", csrfToken)
5050
}
5151

@@ -55,7 +55,7 @@ export default function createApi<TagTypes extends string = never>({
5555

5656
const api = _createApi({
5757
// https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery
58-
baseQuery: async (args, api, extraOptions) => {
58+
baseQuery: async (args: string | FetchArgs, api, extraOptions) => {
5959
if (api.type === "mutation" && getCsrfCookie() === undefined) {
6060
// Get the CSRF token.
6161
const { error } = await fetch(

src/api/endpoints/authFactor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
22

33
import {
4-
buildUrl,
5-
tagData,
64
type ListArg as _ListArg,
75
type ListResult as _ListResult,
6+
buildUrl,
7+
tagData,
88
} from "../../utils/api"
99
import type { AuthFactor } from "../models"
1010
import { type TagTypes } from "../tagTypes"

src/api/endpoints/klass.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
22

3+
import type {
4+
Class,
5+
SchoolTeacher,
6+
SchoolTeacherUser,
7+
Teacher,
8+
} from "../models"
39
import {
4-
buildUrl,
5-
tagData,
610
type ListArg as _ListArg,
711
type ListResult as _ListResult,
812
type RetrieveArg as _RetrieveArg,
913
type RetrieveResult as _RetrieveResult,
14+
buildUrl,
15+
tagData,
1016
} from "../../utils/api"
11-
import type {
12-
Class,
13-
Teacher,
14-
SchoolTeacher,
15-
SchoolTeacherUser,
16-
} from "../models"
1717
import { type TagTypes } from "../tagTypes"
1818
import urls from "../urls"
1919

src/api/endpoints/school.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
22

33
import {
4-
buildUrl,
5-
tagData,
64
type RetrieveArg as _RetrieveArg,
75
type RetrieveResult as _RetrieveResult,
6+
buildUrl,
7+
tagData,
88
} from "../../utils/api"
99
import type { School } from "../models"
1010
import { type TagTypes } from "../tagTypes"

src/api/endpoints/session.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type EndpointBuilder, type Api } from "@reduxjs/toolkit/query/react"
1+
import { type Api, type EndpointBuilder } from "@reduxjs/toolkit/query/react"
22

33
import { login, logout } from "../../slices/session"
44

@@ -39,6 +39,7 @@ export function buildLogoutEndpoint<ResultType, QueryArg>(
3939
console.error("Failed to call logout endpoint...", error)
4040
} finally {
4141
dispatch(logout())
42+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
4243
dispatch(api.util.resetApiState())
4344
}
4445
},

src/api/endpoints/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
22

3+
import type { Class, User } from "../models"
34
import {
4-
buildUrl,
5-
tagData,
65
type ListArg as _ListArg,
76
type ListResult as _ListResult,
87
type RetrieveArg as _RetrieveArg,
98
type RetrieveResult as _RetrieveResult,
9+
buildUrl,
10+
tagData,
1011
} from "../../utils/api"
11-
import type { Class, User } from "../models"
1212
import { type TagTypes } from "../tagTypes"
1313
import urls from "../urls"
1414

src/api/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Model } from "../utils/api"
21
import type { CountryIsoCodes, UkCounties } from "../utils/general"
2+
import type { Model } from "../utils/api"
33

44
// -----------------------------------------------------------------------------
55
// User Models

src/api/schemas.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import * as yup from "yup"
22

3-
import { UK_COUNTIES, COUNTRY_ISO_CODES } from "../utils/general"
43
import type {
5-
User,
6-
TeacherUser,
7-
SchoolTeacherUser,
4+
AdminSchoolTeacher,
85
AdminSchoolTeacherUser,
9-
NonAdminSchoolTeacherUser,
10-
NonSchoolTeacherUser,
11-
Teacher,
12-
Student,
13-
Class,
14-
School,
156
AuthFactor,
16-
OtpBypassToken,
17-
StudentUser,
7+
Class,
188
IndependentUser,
19-
SchoolTeacher,
20-
AdminSchoolTeacher,
219
NonAdminSchoolTeacher,
10+
NonAdminSchoolTeacherUser,
2211
NonSchoolTeacher,
12+
NonSchoolTeacherUser,
13+
OtpBypassToken,
14+
School,
15+
SchoolTeacher,
16+
SchoolTeacherUser,
17+
Student,
18+
StudentUser,
19+
Teacher,
20+
TeacherUser,
21+
User,
2322
} from "./models"
23+
import { COUNTRY_ISO_CODES, UK_COUNTIES } from "../utils/general"
2424
import {
25-
unicodeAlphanumericString,
26-
uppercaseAsciiAlphanumericString,
2725
lowercaseAsciiAlphanumericString,
2826
numericId,
27+
unicodeAlphanumericString,
28+
uppercaseAsciiAlphanumericString,
2929
} from "../utils/schema"
3030
import { type Schemas } from "../utils/api"
3131

0 commit comments

Comments
 (0)