Skip to content

Commit d753f0e

Browse files
committed
Fix redudant types
1 parent 0c1f210 commit d753f0e

35 files changed

+58
-68
lines changed

site/.eslintrc.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ rules:
7575
"@typescript-eslint/restrict-template-expressions": "off"
7676
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
7777
"@typescript-eslint/unbound-method": "off"
78-
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
79-
"@typescript-eslint/no-redundant-type-constituents": "off"
8078
# We're disabling the `no-namespace` rule to use a pattern of defining an interface,
8179
# and then defining functions that operate on that data via namespace. This is helpful for
8280
# dealing with immutable objects. This is a common pattern that shows up in some other

site/src/api/errors.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const mapApiErrorToFieldErrors = (
5959
* @returns error's message if ApiError or Error, else defaultMessage
6060
*/
6161
export const getErrorMessage = (
62-
error: Error | ApiError | unknown,
62+
error: unknown,
6363
defaultMessage: string,
6464
): string =>
6565
isApiError(error)
@@ -74,19 +74,15 @@ export const getErrorMessage = (
7474
* @returns a combined validation error message if the error is an ApiError
7575
* and contains validation messages for different form fields.
7676
*/
77-
export const getValidationErrorMessage = (
78-
error: Error | ApiError | unknown,
79-
): string => {
77+
export const getValidationErrorMessage = (error: unknown): string => {
8078
const validationErrors =
8179
isApiError(error) && error.response.data.validations
8280
? error.response.data.validations
8381
: []
8482
return validationErrors.map((error) => error.detail).join("\n")
8583
}
8684

87-
export const getErrorDetail = (
88-
error: Error | ApiError | unknown,
89-
): string | undefined | null =>
85+
export const getErrorDetail = (error: unknown): string | undefined | null =>
9086
isApiError(error)
9187
? error.response.data.detail
9288
: error instanceof Error

site/src/components/DeploySettingsLayout/Option.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { makeStyles } from "@mui/styles"
2-
import { PropsWithChildren, FC, ReactNode } from "react"
2+
import { PropsWithChildren, FC } from "react"
33
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
44
import { DisabledBadge, EnabledBadge } from "./Badges"
55

@@ -19,9 +19,7 @@ const NotSet: FC = () => {
1919
return <span className={styles.optionValue}>Not set</span>
2020
}
2121

22-
export const OptionValue: FC<{ children?: ReactNode | unknown }> = ({
23-
children,
24-
}) => {
22+
export const OptionValue: FC<{ children?: unknown }> = ({ children }) => {
2523
const styles = useStyles()
2624

2725
if (typeof children === "boolean") {

site/src/components/DeploySettingsLayout/Options.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const defaultOption: DeploymentOption = {
1313
describe("optionValue", () => {
1414
it.each<{
1515
option: DeploymentOption
16-
expected: string | string[] | unknown
16+
expected: unknown
1717
}>([
1818
{
1919
option: {

site/src/components/DeploySettingsLayout/OptionsTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ const OptionsTable: FC<{
6262
}
6363

6464
// optionValue is a helper function to format the value of a specific deployment options
65-
export function optionValue(
66-
option: DeploymentOption,
67-
): string[] | string | unknown {
65+
export function optionValue(option: DeploymentOption) {
6866
switch (option.name) {
6967
case "Max Token Lifetime":
7068
case "Session Duration":

site/src/components/SettingsAccountForm/SettingsAccountForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface AccountFormProps {
3131
isLoading: boolean
3232
initialValues: AccountFormValues
3333
onSubmit: (values: AccountFormValues) => void
34-
updateProfileError?: Error | unknown
34+
updateProfileError?: unknown
3535
// initialTouched is only used for testing the error state of the form.
3636
initialTouched?: FormikTouched<AccountFormValues>
3737
}

site/src/components/Workspace/Workspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface WorkspaceProps {
6464
canChangeVersions: boolean
6565
hideSSHButton?: boolean
6666
hideVSCodeDesktopButton?: boolean
67-
workspaceErrors: Partial<Record<WorkspaceErrors, Error | unknown>>
67+
workspaceErrors: Partial<Record<WorkspaceErrors, unknown>>
6868
buildInfo?: TypesGen.BuildInfoResponse
6969
sshPrefix?: string
7070
template?: TypesGen.Template

site/src/components/WorkspacesTable/WorkspacesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface WorkspacesTableProps {
1919
workspaces?: Workspace[]
2020
isUsingFilter: boolean
2121
onUpdateWorkspace: (workspace: Workspace) => void
22-
error?: Error | unknown
22+
error?: unknown
2323
}
2424

2525
export const WorkspacesTable: FC<WorkspacesTableProps> = ({

site/src/components/WorkspacesTable/WorkspacesTableBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface TableBodyProps {
1414
workspaces?: Workspace[]
1515
isUsingFilter: boolean
1616
onUpdateWorkspace: (workspace: Workspace) => void
17-
error?: Error | unknown
17+
error?: unknown
1818
}
1919

2020
export const WorkspacesTableBody: FC<

site/src/contexts/ProxyContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface ProxyContextValue {
4646
// isFetched is true when the 'proxies' api call is complete.
4747
isFetched: boolean
4848
isLoading: boolean
49-
error?: Error | unknown
49+
error?: unknown
5050
// proxyLatencies is a map of proxy id to latency report. If the proxyLatencies[proxy.id] is undefined
5151
// then the latency has not been fetched yet. Calculations happen async for each proxy in the list.
5252
// Refer to the returned report for a given proxy for more information.

site/src/pages/AuditPage/AuditPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface AuditPageViewProps {
3737
onPageChange: (page: number) => void
3838
isNonInitialPage: boolean
3939
isAuditLogVisible: boolean
40-
error?: Error | unknown
40+
error?: unknown
4141
filterProps: ComponentProps<typeof AuditFilter>
4242
}
4343

site/src/pages/CreateTokenPage/CreateTokenForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { Stack } from "components/Stack/Stack"
2525
interface CreateTokenFormProps {
2626
form: FormikContextType<CreateTokenData>
2727
maxTokenLifetime?: number
28-
formError: Error | unknown
29-
setFormError: (arg0: Error | unknown) => void
28+
formError: unknown
29+
setFormError: (arg0: unknown) => void
3030
isCreating: boolean
3131
creationFailed: boolean
3232
}

site/src/pages/CreateTokenPage/CreateTokenPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const CreateTokenPage: FC = () => {
4343
queryFn: getTokenConfig,
4444
})
4545

46-
const [formError, setFormError] = useState<unknown | undefined>(undefined)
46+
const [formError, setFormError] = useState<unknown>(undefined)
4747

4848
const onCreateSuccess = () => {
4949
displaySuccess(t("createToken.createSuccess"))

site/src/pages/GroupsPage/CreateGroupPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const validationSchema = Yup.object({
1616

1717
export type CreateGroupPageViewProps = {
1818
onSubmit: (data: CreateGroupRequest) => void
19-
formErrors: unknown | undefined
19+
formErrors?: unknown
2020
isLoading: boolean
2121
}
2222

site/src/pages/UserSettingsPage/SSHKeysPage/SSHKeysPageView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export const Language = {
1515
export interface SSHKeysPageViewProps {
1616
isLoading: boolean
1717
hasLoaded: boolean
18-
getSSHKeyError?: Error | unknown
19-
regenerateSSHKeyError?: Error | unknown
18+
getSSHKeyError?: unknown
19+
regenerateSSHKeyError?: unknown
2020
sshKey?: GitSSHKey
2121
onRegenerateClick: () => void
2222
}

site/src/pages/UserSettingsPage/TokensPage/TokensPageView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const lastUsedOrNever = (lastUsed: string) => {
2828

2929
export interface TokensPageViewProps {
3030
tokens?: APIKeyWithOwner[]
31-
getTokensError?: Error | unknown
31+
getTokensError?: unknown
3232
isLoading: boolean
3333
hasLoaded: boolean
3434
onDelete: (token: APIKeyWithOwner) => void
35-
deleteTokenError?: Error | unknown
35+
deleteTokenError?: unknown
3636
}
3737

3838
export const TokensPageView: FC<

site/src/pages/UserSettingsPage/WorkspaceProxyPage/WorkspaceProxyView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import { ErrorAlert } from "components/Alert/ErrorAlert"
1717
export interface WorkspaceProxyViewProps {
1818
proxies?: Region[]
1919
proxyLatencies?: Record<string, ProxyLatencyReport>
20-
getWorkspaceProxiesError?: Error | unknown
20+
getWorkspaceProxiesError?: unknown
2121
isLoading: boolean
2222
hasLoaded: boolean
2323
preferredProxy?: Region
24-
selectProxyError?: Error | unknown
24+
selectProxyError?: unknown
2525
}
2626

2727
export const WorkspaceProxyView: FC<

site/src/xServices/appearance/appearanceXService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { AppearanceConfig } from "../../api/typesGenerated"
55

66
export type AppearanceContext = {
77
appearance?: AppearanceConfig
8-
getAppearanceError?: Error | unknown
9-
setAppearanceError?: Error | unknown
8+
getAppearanceError?: unknown
9+
setAppearanceError?: unknown
1010
preview: boolean
1111
}
1212

site/src/xServices/auth/authMethodsXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as API from "api/api"
44

55
export interface AuthMethodsContext {
66
authMethods?: TypeGen.AuthMethods
7-
error?: Error | unknown
7+
error?: unknown
88
}
99

1010
export const authMethodsXService = createMachine(

site/src/xServices/auth/authXService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ const signOut = async () => {
181181
} as UnauthenticatedData
182182
}
183183
export interface AuthContext {
184-
error?: Error | unknown
185-
updateProfileError?: Error | unknown
184+
error?: unknown
185+
updateProfileError?: unknown
186186
data?: AuthData
187187
}
188188

site/src/xServices/buildInfo/buildInfoXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as API from "../../api/api"
33
import * as TypesGen from "../../api/typesGenerated"
44

55
export interface BuildInfoContext {
6-
getBuildInfoError?: Error | unknown
6+
getBuildInfoError?: unknown
77
buildInfo?: TypesGen.BuildInfoResponse
88
}
99

site/src/xServices/createWorkspace/createWorkspaceXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type CreateWorkspaceContext = {
2525
templateName: string
2626
mode: CreateWorkspaceMode
2727
defaultName: string
28-
error?: Error | unknown
28+
error?: unknown
2929
// Form
3030
template?: Template
3131
parameters?: TemplateVersionParameter[]

site/src/xServices/entitlements/entitlementsXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Entitlements } from "../../api/typesGenerated"
44

55
export type EntitlementsContext = {
66
entitlements?: Entitlements
7-
getEntitlementsError?: Error | unknown
7+
getEntitlementsError?: unknown
88
}
99

1010
export const entitlementsMachine = createMachine(

site/src/xServices/experiments/experimentsMachine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createMachine, assign } from "xstate"
44

55
export interface ExperimentsContext {
66
experiments?: Experiment[]
7-
getExperimentsError?: Error | unknown
7+
getExperimentsError?: unknown
88
}
99

1010
export const experimentsMachine = createMachine(

site/src/xServices/quotas/quotasXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { WorkspaceQuota } from "../../api/typesGenerated"
55
export type QuotaContext = {
66
username: string
77
quota?: WorkspaceQuota
8-
getQuotaError?: Error | unknown
8+
getQuotaError?: unknown
99
}
1010

1111
export const quotaMachine = createMachine(

site/src/xServices/roles/siteRolesXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const Language = {
1010
type SiteRolesContext = {
1111
hasPermission: boolean
1212
roles?: TypesGen.AssignableRoles[]
13-
getRolesError: Error | unknown
13+
getRolesError: unknown
1414
}
1515

1616
export const siteRolesMachine = createMachine(

site/src/xServices/template/templateVariablesXService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type TemplateVariablesContext = {
2424
createTemplateVersionRequest?: CreateTemplateVersionRequest
2525
newTemplateVersion?: TemplateVersion
2626

27-
getTemplateDataError?: Error | unknown
28-
updateTemplateError?: Error | unknown
27+
getTemplateDataError?: unknown
28+
updateTemplateError?: unknown
2929

3030
jobError?: TemplateVersion["job"]["error"]
3131
}

site/src/xServices/templateVersion/templateVersionXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface TemplateVersionMachineContext {
1818
template?: Template
1919
currentVersion?: TemplateVersion
2020
currentFiles?: TemplateVersionFiles
21-
error?: Error | unknown
21+
error?: unknown
2222
// Get file diffs
2323
previousVersion?: TemplateVersion
2424
previousFiles?: TemplateVersionFiles

site/src/xServices/templates/templatesXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface TemplatesContext {
88
permissions: Permissions
99
templates?: TypesGen.Template[]
1010
examples?: TypesGen.TemplateExample[]
11-
error?: Error | unknown
11+
error?: unknown
1212
}
1313

1414
export const templatesMachine = createMachine(

site/src/xServices/terminal/terminalXService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import * as Types from "../../api/types"
44
import * as TypesGen from "../../api/typesGenerated"
55

66
export interface TerminalContext {
7-
workspaceError?: Error | unknown
7+
workspaceError?: unknown
88
workspace?: TypesGen.Workspace
99
workspaceAgent?: TypesGen.WorkspaceAgent
10-
workspaceAgentError?: Error | unknown
10+
workspaceAgentError?: unknown
1111
websocket?: WebSocket
12-
websocketError?: Error | unknown
12+
websocketError?: unknown
1313
websocketURL?: string
14-
websocketURLError?: Error | unknown
14+
websocketURLError?: unknown
1515

1616
// Assigned by connecting!
1717
// The workspace agent is entirely optional. If the agent is omitted the

site/src/xServices/updateCheck/updateCheckXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { checks, Permissions } from "xServices/auth/authXService"
66
export interface UpdateCheckContext {
77
permissions: Permissions
88
updateCheck?: UpdateCheckResponse
9-
error?: Error | unknown
9+
error?: unknown
1010
}
1111

1212
export type UpdateCheckEvent = { type: "DISMISS" }

site/src/xServices/users/usersXService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ export interface UsersContext {
3535
// Get users
3636
users?: TypesGen.User[]
3737
filter: string
38-
getUsersError?: Error | unknown
38+
getUsersError?: unknown
3939
// Suspend user
4040
userIdToSuspend?: TypesGen.User["id"]
4141
usernameToSuspend?: TypesGen.User["username"]
42-
suspendUserError?: Error | unknown
42+
suspendUserError?: unknown
4343
// Delete user
4444
userIdToDelete?: TypesGen.User["id"]
4545
usernameToDelete?: TypesGen.User["username"]
46-
deleteUserError?: Error | unknown
46+
deleteUserError?: unknown
4747
// Activate user
4848
userIdToActivate?: TypesGen.User["id"]
4949
usernameToActivate?: TypesGen.User["username"]
50-
activateUserError?: Error | unknown
50+
activateUserError?: unknown
5151
// Reset user password
5252
userIdToResetPassword?: TypesGen.User["id"]
53-
resetUserPasswordError?: Error | unknown
53+
resetUserPasswordError?: unknown
5454
newUserPassword?: string
5555
// Update user roles
5656
userIdToUpdateRoles?: TypesGen.User["id"]
57-
updateUserRolesError?: Error | unknown
57+
updateUserRolesError?: unknown
5858
paginationContext: PaginationContext
5959
paginationRef: PaginationMachineRef
6060
count: number

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ export interface WorkspaceContext {
5959
build?: TypesGen.WorkspaceBuild
6060
// Builds
6161
builds?: TypesGen.WorkspaceBuild[]
62-
getBuildsError?: Error | unknown
62+
getBuildsError?: unknown
6363
missedParameters?: TypesGen.TemplateVersionParameter[]
6464
// error creating a new WorkspaceBuild
65-
buildError?: Error | unknown
65+
buildError?: unknown
6666
cancellationMessage?: Types.Message
67-
cancellationError?: Error | unknown
67+
cancellationError?: unknown
6868
// debug
6969
createBuildLogLevel?: TypesGen.CreateWorkspaceBuildRequest["log_level"]
7070
// SSH Config
@@ -92,7 +92,7 @@ export type WorkspaceEvent =
9292
checkRefresh?: boolean
9393
data?: TypesGen.ServerSentEvent["data"]
9494
}
95-
| { type: "EVENT_SOURCE_ERROR"; error: Error | unknown }
95+
| { type: "EVENT_SOURCE_ERROR"; error: unknown }
9696
| { type: "INCREASE_DEADLINE"; hours: number }
9797
| { type: "DECREASE_DEADLINE"; hours: number }
9898
| { type: "RETRY_BUILD" }

0 commit comments

Comments
 (0)