diff --git a/src/commands/addons/addons-config.ts b/src/commands/addons/addons-config.ts index 9d23fe36380..2d2698b0224 100644 --- a/src/commands/addons/addons-config.ts +++ b/src/commands/addons/addons-config.ts @@ -8,7 +8,7 @@ import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepar import generatePrompts from '../../utils/addons/prompts.js' import { renderConfigValues } from '../../utils/addons/render.js' import { missingConfigValues, requiredConfigValues, updateConfigValues } from '../../utils/addons/validation.js' -import { chalk, error, log } from '../../utils/command-helpers.js' +import { chalk, error, log, APIError } from '../../utils/command-helpers.js' import { parseRawFlags } from '../../utils/parse-raw-flags.js' import BaseCommand from '../base-command.js' @@ -35,8 +35,7 @@ const update = async function ({ addonName, api, currentConfig, instanceId, newC }) log(`Add-on "${addonName}" successfully updated`) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } diff --git a/src/commands/addons/addons-create.ts b/src/commands/addons/addons-create.ts index 1fa244725d3..4453f87edba 100644 --- a/src/commands/addons/addons-create.ts +++ b/src/commands/addons/addons-create.ts @@ -6,7 +6,7 @@ import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepar import generatePrompts from '../../utils/addons/prompts.js' import { renderConfigValues, renderMissingValues } from '../../utils/addons/render.js' import { missingConfigValues, requiredConfigValues, updateConfigValues } from '../../utils/addons/validation.js' -import { chalk, error, log } from '../../utils/command-helpers.js' +import { chalk, error, log, APIError } from '../../utils/command-helpers.js' import { parseRawFlags } from '../../utils/parse-raw-flags.js' import BaseCommand from '../base-command.js' // @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message @@ -23,8 +23,7 @@ const createAddon = async ({ addonName, api, config, siteData, siteId }) => { log(`${response.config.message}`) } } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } diff --git a/src/commands/addons/addons-delete.ts b/src/commands/addons/addons-delete.ts index 32f9e46eb61..dee08cf0d7a 100644 --- a/src/commands/addons/addons-delete.ts +++ b/src/commands/addons/addons-delete.ts @@ -2,7 +2,7 @@ import { OptionValues } from 'commander' import inquirer from 'inquirer' import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.js' -import { error, exit, log } from '../../utils/command-helpers.js' +import { error, exit, log, APIError } from '../../utils/command-helpers.js' import BaseCommand from '../base-command.js' export const addonsDelete = async (addonName: string, options: OptionValues, command: BaseCommand) => { @@ -31,7 +31,6 @@ export const addonsDelete = async (addonName: string, options: OptionValues, com }) log(`Addon "${addonName}" deleted`) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } diff --git a/src/commands/api/api.ts b/src/commands/api/api.ts index 10caa2d127c..b594b1646dd 100644 --- a/src/commands/api/api.ts +++ b/src/commands/api/api.ts @@ -40,7 +40,6 @@ export const apiCommand = async (apiMethod: string, options: OptionValues, comma const apiResponse = await api[apiMethod](payload) logJson(apiResponse) } catch (error_) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/commands/base-command.ts b/src/commands/base-command.ts index 592f464b755..f8a7c469124 100644 --- a/src/commands/base-command.ts +++ b/src/commands/base-command.ts @@ -725,7 +725,6 @@ export default class BaseCommand extends Command { // the option to say that we don't need API data.) if (isUserError && !config.offline && config.token) { if (flags.debug) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_, { exit: false }) warn('Failed to resolve config, falling back to offline resolution') } diff --git a/src/commands/deploy/deploy.ts b/src/commands/deploy/deploy.ts index 2624362593f..098d6c1e14e 100644 --- a/src/commands/deploy/deploy.ts +++ b/src/commands/deploy/deploy.ts @@ -30,6 +30,7 @@ import { log, logJson, warn, + APIError, } from '../../utils/command-helpers.js' import { DEFAULT_DEPLOY_TIMEOUT } from '../../utils/deploy/constants.js' import { deploySite } from '../../utils/deploy/deploy-site.js' @@ -58,12 +59,10 @@ const triggerDeploy = async ({ api, options, siteData, siteId }) => { ) } } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error('Site not found. Please rerun "netlify link" and make sure that your site has CI configured.') } else { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } } diff --git a/src/commands/functions/functions-create.ts b/src/commands/functions/functions-create.ts index 1fcf7fe4781..40bacd10617 100644 --- a/src/commands/functions/functions-create.ts +++ b/src/commands/functions/functions-create.ts @@ -15,7 +15,15 @@ import ora from 'ora' import { fileExistsAsync } from '../../lib/fs.js' import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js' -import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.js' +import { + APIError, + NETLIFYDEVERR, + NETLIFYDEVLOG, + NETLIFYDEVWARN, + chalk, + error, + log, +} from '../../utils/command-helpers.js' import { copyTemplateDir } from '../../utils/copy-template-dir/copy-template-dir.js' import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js' import execa from '../../utils/execa.js' @@ -492,7 +500,6 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun await downloadFromURL(command, options, argumentName, functionsDir) } catch (error_) { error(`$${NETLIFYDEVERR} Error downloading from URL: ${options.url}`) - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) process.exit(1) } @@ -583,8 +590,7 @@ const createFunctionAddon = async function ({ addonName, addons, api, siteData, log(`Add-on "${addonName}" created for ${siteData.name}`) return true } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } @@ -682,8 +688,7 @@ const installAddons = async function (command, functionAddons, fnPath) { await handleAddonDidInstall({ addonCreated, addonDidInstall, command, fnPath }) } catch (error_) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message - error(`${NETLIFYDEVERR} Error installing addon: `, error_) + error(`${NETLIFYDEVERR} Error installing addon: ${error_}`) } }) return Promise.all(arr) diff --git a/src/commands/functions/functions-invoke.ts b/src/commands/functions/functions-invoke.ts index 0ca0da575f0..f8af526ba4d 100644 --- a/src/commands/functions/functions-invoke.ts +++ b/src/commands/functions/functions-invoke.ts @@ -6,7 +6,7 @@ import { OptionValues } from 'commander' import inquirer from 'inquirer' import fetch from 'node-fetch' -import { NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.js' +import { APIError, NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.js' import { BACKGROUND, CLOCKWORK_USERAGENT, getFunctions } from '../../utils/functions/index.js' import BaseCommand from '../base-command.js' @@ -234,7 +234,6 @@ export const functionsInvoke = async (nameArgument: string, options: OptionValue const data = await response.text() console.log(data) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Ran into an error invoking your function: ${error_.message}`) + error(`Ran into an error invoking your function: ${(error_ as APIError).message}`) } } diff --git a/src/commands/link/link.ts b/src/commands/link/link.ts index 30889cb2525..31be9b20fc3 100644 --- a/src/commands/link/link.ts +++ b/src/commands/link/link.ts @@ -3,7 +3,7 @@ import inquirer from 'inquirer' import isEmpty from 'lodash/isEmpty.js' import { listSites } from '../../lib/api.js' -import { chalk, error, exit, log } from '../../utils/command-helpers.js' +import { chalk, error, exit, log, APIError } from '../../utils/command-helpers.js' import getRepoData from '../../utils/get-repo-data.js' import { ensureNetlifyIgnore } from '../../utils/gitignore.js' import { track } from '../../utils/telemetry/index.js' @@ -125,11 +125,9 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`) options: { name: searchTerm, filter: 'all' }, }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error(`'${searchTerm}' not found`) } else { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -172,7 +170,6 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) try { sites = await listSites({ api, options: { maxPages: 1, filter: 'all' } }) } catch (error_) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } @@ -209,11 +206,9 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) try { site = await api.getSite({ siteId }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { - error(new Error(`Site ID '${siteId}' not found`)) + if ((error_ as APIError).status === 404) { + error(`Site ID '${siteId}' not found`) } else { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -281,11 +276,9 @@ export const link = async (options: OptionValues, command: BaseCommand) => { try { siteData = await api.getSite({ site_id: options.id }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error(new Error(`Site id ${options.id} not found`)) } else { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -310,11 +303,9 @@ export const link = async (options: OptionValues, command: BaseCommand) => { }, }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error(new Error(`${options.name} not found`)) } else { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/commands/lm/lm-setup.ts b/src/commands/lm/lm-setup.ts index 409b0fad854..f32940ab4c5 100644 --- a/src/commands/lm/lm-setup.ts +++ b/src/commands/lm/lm-setup.ts @@ -65,7 +65,6 @@ export const lmSetup = async (options: OptionValues, command: BaseCommand) => { try { helperInstalled = await installHelperIfMissing({ force: options.forceInstall }) } catch (error_) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/commands/sites/sites-create-template.ts b/src/commands/sites/sites-create-template.ts index ff2747f1086..5a88d6b8c2c 100644 --- a/src/commands/sites/sites-create-template.ts +++ b/src/commands/sites/sites-create-template.ts @@ -5,7 +5,7 @@ import pick from 'lodash/pick.js' import parseGitHubUrl from 'parse-github-url' import { render } from 'prettyjson' -import { chalk, error, getTerminalLink, log, logJson, warn } from '../../utils/command-helpers.js' +import { chalk, error, getTerminalLink, log, logJson, warn, APIError } from '../../utils/command-helpers.js' import execa from '../../utils/execa.js' import getRepoData from '../../utils/get-repo-data.js' import { getGitHubToken } from '../../utils/init/config-github.js' @@ -163,16 +163,14 @@ export const sitesCreateTemplate = async (repository: string, options: OptionVal }) } } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 422 || error_.message === 'Duplicate repo') { + if ((error_ as APIError).status === 422 || (error_ as APIError).message === 'Duplicate repo') { warn( `${name}.netlify.app already exists or a repository named ${name} already exists on this account. Please try a different slug.`, ) // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. await inputSiteName() } else { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`createSiteInTeam error: ${error_.status}: ${error_.message}`) + error(`createSiteInTeam error: ${(error_ as APIError).status}: ${(error_ as APIError).message}`) } } } diff --git a/src/commands/sites/sites-create.ts b/src/commands/sites/sites-create.ts index c7a21f3d81a..5fcbf5f2d16 100644 --- a/src/commands/sites/sites-create.ts +++ b/src/commands/sites/sites-create.ts @@ -3,7 +3,7 @@ import inquirer from 'inquirer' import pick from 'lodash/pick.js' import prettyjson from 'prettyjson' -import { chalk, error, log, logJson, warn } from '../../utils/command-helpers.js' +import { chalk, error, log, logJson, warn, APIError } from '../../utils/command-helpers.js' import getRepoData from '../../utils/get-repo-data.js' import { configureRepo } from '../../utils/init/config.js' import { track } from '../../utils/telemetry/index.js' @@ -70,14 +70,12 @@ export const sitesCreate = async (options: OptionValues, command: BaseCommand) = body, }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 422) { + if ((error_ as APIError).status === 422) { warn(`${siteName}.netlify.app already exists. Please try a different slug.`) // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. await inputSiteName() } else { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`createSiteInTeam error: ${error_.status}: ${error_.message}`) + error(`createSiteInTeam error: ${(error_ as APIError).status}: ${(error_ as APIError).message}`) } } } diff --git a/src/commands/sites/sites-delete.ts b/src/commands/sites/sites-delete.ts index 70956c893c3..512fab816ff 100644 --- a/src/commands/sites/sites-delete.ts +++ b/src/commands/sites/sites-delete.ts @@ -1,7 +1,7 @@ import { OptionValues } from 'commander' import inquirer from 'inquirer' -import { chalk, error, exit, log } from '../../utils/command-helpers.js' +import { chalk, error, exit, log, APIError } from '../../utils/command-helpers.js' import BaseCommand from '../base-command.js' export const sitesDelete = async (siteId: string, options: OptionValues, command: BaseCommand) => { @@ -17,9 +17,10 @@ export const sitesDelete = async (siteId: string, options: OptionValues, command try { siteData = await api.getSite({ siteId }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error(`No site with id ${siteId} found. Please verify the siteId & try again.`) + } else { + error(error_) } } @@ -74,12 +75,10 @@ export const sitesDelete = async (siteId: string, options: OptionValues, command try { await api.deleteSite({ site_id: siteId }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { error(`No site with id ${siteId} found. Please verify the siteId & try again.`) } else { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Delete Site error: ${error_.status}: ${error_.message}`) + error(`Delete Site error: ${(error_ as APIError).status}: ${(error_ as APIError).message}`) } } log(`Site "${siteId}" successfully deleted!`) diff --git a/src/commands/status/status.ts b/src/commands/status/status.ts index 15cf6b745f5..1a14e3592bb 100644 --- a/src/commands/status/status.ts +++ b/src/commands/status/status.ts @@ -2,7 +2,7 @@ import clean from 'clean-deep' import { OptionValues } from 'commander' import prettyjson from 'prettyjson' -import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.js' +import { chalk, error, exit, getToken, log, logJson, warn, APIError } from '../../utils/command-helpers.js' import BaseCommand from '../base-command.js' export const status = async (options: OptionValues, command: BaseCommand) => { @@ -31,9 +31,10 @@ export const status = async (options: OptionValues, command: BaseCommand) => { // eslint-disable-next-line @typescript-eslint/no-extra-semi ;[accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 401) { + if ((error_ as APIError).status === 401) { error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.') + } else { + error(error_) } } diff --git a/src/commands/watch/watch.ts b/src/commands/watch/watch.ts index 071ccce8b02..2bf7a016878 100644 --- a/src/commands/watch/watch.ts +++ b/src/commands/watch/watch.ts @@ -114,7 +114,6 @@ export const watch = async (options: OptionValues, command: BaseCommand) => { ) console.timeEnd('Deploy time') } catch (error_) { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/lib/exec-fetcher.ts b/src/lib/exec-fetcher.ts index 3a1910f0877..ea703eaa157 100644 --- a/src/lib/exec-fetcher.ts +++ b/src/lib/exec-fetcher.ts @@ -148,8 +148,6 @@ export const fetchLatestVersion = async ({ destination, execName, extension, lat Please open up an issue on our CLI repository so that we can support it: ${issueLink}`) } - - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/utils/addons/prepare.ts b/src/utils/addons/prepare.ts index 3a31e07b077..2b0342429df 100644 --- a/src/utils/addons/prepare.ts +++ b/src/utils/addons/prepare.ts @@ -1,4 +1,4 @@ -import { chalk, error, exit, log, warn } from '../command-helpers.js' +import { APIError, chalk, error, exit, log, warn } from '../command-helpers.js' export const ADDON_VALIDATION = { EXISTS: 'EXISTS', @@ -55,12 +55,10 @@ export const getAddonManifest = async ({ addonName, api }) => { try { manifest = await api.showServiceManifest({ addonName }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (typeof error_.message === 'string' && error_.message.includes('Not Found')) { + if ((error_ as APIError).message.includes('Not Found')) { error(`No add-on "${addonName}" found. Please double check your add-on name and try again`) } else { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(error_.message) + error((error_ as APIError).message) } } return manifest @@ -72,8 +70,7 @@ export const getSiteData = async ({ api, siteId }) => { try { siteData = await api.getSite({ siteId }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Failed getting list of site data: ${error_.message}`) + error(`Failed getting list of site data: ${(error_ as APIError).message}`) } return siteData } @@ -84,8 +81,7 @@ export const getAddons = async ({ api, siteId }) => { try { addons = await api.listServiceInstancesForSite({ siteId }) } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Failed getting list of addons: ${error_.message}`) + error(`Failed getting list of addons: ${(error_ as APIError).message}`) } return addons } diff --git a/src/utils/command-helpers.ts b/src/utils/command-helpers.ts index c71311bb7a2..1ea8c39a2cf 100644 --- a/src/utils/command-helpers.ts +++ b/src/utils/command-helpers.ts @@ -112,7 +112,6 @@ export const pollForToken = async ({ api, ticket }) => { )}, then run ${chalk.cyanBright('netlify login')} again.`, ) } else { - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } finally { @@ -186,7 +185,7 @@ export const warn = (message = '') => { } /** Throws an error or logs it */ -export const error = (message: Error | string = '', options: { exit?: boolean } = {}) => { +export const error = (message: unknown | Error | string = '', options: { exit?: boolean } = {}) => { const err = message instanceof Error ? message @@ -300,3 +299,8 @@ export const nonNullable = (value: T): value is NonNullable => value !== n export const noOp = () => { // no-op } + +export interface APIError extends Error { + status: number + message: string +} diff --git a/src/utils/dev.ts b/src/utils/dev.ts index 3d2fd51d335..5e08de4aafd 100644 --- a/src/utils/dev.ts +++ b/src/utils/dev.ts @@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty.js' import { supportsBackgroundFunctions } from '../lib/account.js' -import { NETLIFYDEVLOG, chalk, error, log, warn } from './command-helpers.js' +import { NETLIFYDEVLOG, chalk, error, log, warn, APIError } from './command-helpers.js' import { loadDotEnvFiles } from './dot-env.js' // Possible sources of environment variables. For the purpose of printing log messages only. Order does not matter. @@ -52,8 +52,7 @@ const getAccounts = async ({ api }) => { const accounts = await api.listAccountsForUser() return accounts } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Failed retrieving user account: ${error_.message}. ${ERROR_CALL_TO_ACTION}`) + error(`Failed retrieving user account: ${(error_ as APIError).message}. ${ERROR_CALL_TO_ACTION}`) } } @@ -63,8 +62,11 @@ const getAddons = async ({ api, site }) => { const addons = await api.listServiceInstancesForSite({ siteId: site.id }) return addons } catch (error_) { - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - error(`Failed retrieving addons for site ${chalk.yellow(site.id)}: ${error_.message}. ${ERROR_CALL_TO_ACTION}`) + error( + `Failed retrieving addons for site ${chalk.yellow(site.id)}: ${ + (error_ as APIError).message + }. ${ERROR_CALL_TO_ACTION}`, + ) } } diff --git a/src/utils/framework-server.ts b/src/utils/framework-server.ts index 1b7e97b77bd..b7652a806e2 100644 --- a/src/utils/framework-server.ts +++ b/src/utils/framework-server.ts @@ -70,7 +70,6 @@ export const startFrameworkServer = async function ({ stopSpinner({ error: true, spinner }) log(NETLIFYDEVERR, `Netlify Dev could not start or connect to localhost:${settings.frameworkPort}.`) log(NETLIFYDEVERR, `Please make sure your framework server is running on port ${settings.frameworkPort}`) - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) exit(1) } diff --git a/src/utils/hooks/requires-site-info.ts b/src/utils/hooks/requires-site-info.ts index 69b38e1a5f1..6065dd3c831 100644 --- a/src/utils/hooks/requires-site-info.ts +++ b/src/utils/hooks/requires-site-info.ts @@ -1,4 +1,5 @@ -import { error, warn } from '../command-helpers.js' +import { error, warn, APIError } from '../command-helpers.js' + /** * A preAction hook that errors out if siteInfo is an empty object * @param {*} command @@ -15,17 +16,15 @@ const requiresSiteInfo = async (command) => { await api.getSite({ siteId }) } catch (error_) { // unauthorized - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 401) { + if ((error_ as APIError).status === 401) { warn(`Log in with a different account or re-link to a site you have permission for`) return error(`Not authorized to view the currently linked site (${siteId})`) } // missing - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - if (error_.status === 404) { + if ((error_ as APIError).status === 404) { return error(`The site this folder is linked to can't be found`) } - // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message + return error(error_) } }