1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-03-06 15:36:17 +02:00

Typing adjustment - 1354 (#1416)

* refactor: adjusting typing

* fix: Correction of some typings with unknown
This commit is contained in:
Tiago Santos Da Silva 2021-10-04 06:44:30 -03:00 committed by GitHub
parent 7ce9e44a5d
commit 1d0bb180f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ class OctoClient {
this.serverUrl = serverUrl this.serverUrl = serverUrl
} }
private async getJson(response: Response, defaultValue: any): Promise<any> { private async getJson(response: Response, defaultValue: unknown): Promise<unknown> {
// The server may return null or malformed json // The server may return null or malformed json
try { try {
const value = await response.json() const value = await response.json()
@ -93,7 +93,7 @@ class OctoClient {
return json return json
} }
async register(email: string, username: string, password: string, token?: string): Promise<{code: number, json: any}> { async register(email: string, username: string, password: string, token?: string): Promise<{code: number, json: {error?: string}}> {
const path = '/api/v1/register' const path = '/api/v1/register'
const body = JSON.stringify({email, username, password, token}) const body = JSON.stringify({email, username, password, token})
const response = await fetch(this.getBaseURL() + path, { const response = await fetch(this.getBaseURL() + path, {
@ -101,11 +101,11 @@ class OctoClient {
headers: this.headers(), headers: this.headers(),
body, body,
}) })
const json = (await this.getJson(response, {})) const json = (await this.getJson(response, {})) as {error?: string}
return {code: response.status, json} return {code: response.status, json}
} }
async changePassword(userId: string, oldPassword: string, newPassword: string): Promise<{code: number, json: any}> { async changePassword(userId: string, oldPassword: string, newPassword: string): Promise<{code: number, json: {error?: string}}> {
const path = `/api/v1/users/${encodeURIComponent(userId)}/changepassword` const path = `/api/v1/users/${encodeURIComponent(userId)}/changepassword`
const body = JSON.stringify({oldPassword, newPassword}) const body = JSON.stringify({oldPassword, newPassword})
const response = await fetch(this.getBaseURL() + path, { const response = await fetch(this.getBaseURL() + path, {
@ -113,7 +113,7 @@ class OctoClient {
headers: this.headers(), headers: this.headers(),
body, body,
}) })
const json = (await this.getJson(response, {})) const json = (await this.getJson(response, {})) as {error?: string}
return {code: response.status, json} return {code: response.status, json}
} }
@ -236,7 +236,7 @@ class OctoClient {
// Hydrate is important, as it ensures that each block is complete to the current model // Hydrate is important, as it ensures that each block is complete to the current model
const fixedBlocks = OctoUtils.hydrateBlocks(blocks) const fixedBlocks = OctoUtils.hydrateBlocks(blocks)
// TODO: Remove this fixup code // !TODO: Remove this fixup code
for (const block of fixedBlocks) { for (const block of fixedBlocks) {
if (!block.fields) { if (!block.fields) {
block.fields = {} block.fields = {}

View File

@ -33,7 +33,7 @@ const RegisterPage = React.memo(() => {
} else if (response.code === 401) { } else if (response.code === 401) {
setErrorMessage('Invalid registration link, please contact your administrator') setErrorMessage('Invalid registration link, please contact your administrator')
} else { } else {
setErrorMessage(response.json?.error) setErrorMessage(`${response.json?.error}`)
} }
} }