build: upgrade js/ts

This commit is contained in:
EnixCoda 2022-04-28 00:31:40 +08:00
parent c01ddb8dce
commit bf37b6e7c5
6 changed files with 1375 additions and 744 deletions

View file

@ -26,7 +26,7 @@ export async function scroll({
}
}
export function assert(condition: boolean, err?: Error | string) {
export function assert(condition: boolean, err?: Error | string): asserts condition {
if (!condition) throw typeof err === 'string' ? new Error(err) : err
}

View file

@ -47,35 +47,35 @@
"webextension-polyfill": "^0.5.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.9",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@sentry/cli": "^1.64.2",
"@types/firefox-webext-browser": "^70.0.1",
"@types/jest": "^26.0.23",
"@types/node": "^11.10.4",
"@types/puppeteer": "^5.4.3",
"babel-loader": "^8.0.5",
"babel-loader": "^8.2.5",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"copy-webpack-plugin": "^5.0.0",
"css-loader": "^2.1.0",
"dotenv": "^6.2.0",
"dotenv-webpack": "^1.7.0",
"file-loader": "^3.0.1",
"fork-ts-checker-webpack-plugin": "^0.5.2",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"jest": "^27.0.6",
"jest-puppeteer": "^5.0.4",
"jest-puppeteer": "^6.1.0",
"json-loader": "^0.5.7",
"mini-css-extract-plugin": "^0.9.0",
"puppeteer": "^10.1.0",
"raw-loader": "^4.0.0",
"sass": "^1.26.2",
"sass-loader": "^8.0.2",
"typescript": "^4.2.4",
"typescript": "^4.6.3",
"uglifyjs-webpack-plugin": "^2.1.2",
"url-loader": "^1.1.2",
"web-ext": "^6.8.0",

View file

@ -62,7 +62,7 @@ export const withErrorLog: Middleware = function withErrorLog(method, args) {
try {
await method.apply(null, arguments as any)
} catch (error) {
raiseError(error)
if (error instanceof Error) raiseError(error)
}
} as any, // TO FIX: not sure how to fix this yet
args,

3
src/utils/assert.ts Normal file
View file

@ -0,0 +1,3 @@
export function assert(condition: boolean, errorMessage?: string): asserts condition {
if (!condition) throw new Error(errorMessage)
}

View file

@ -1,6 +1,7 @@
import { useConfigs } from 'containers/ConfigsContext'
import { errors, platformName } from 'platforms'
import { useCallback } from 'react'
import { assert } from 'utils/assert'
import { useLoadedContext } from 'utils/hooks/useLoadedContext'
import { SideBarErrorContext } from '../../containers/ErrorContext'
import { SideBarStateContext } from '../../containers/SideBarState'
@ -15,6 +16,8 @@ export function useCatchNetworkError() {
try {
return await fn() // keep the await so that catch block can catch async errors
} catch (err) {
assert(err instanceof Error)
if (err.message === errors.EMPTY_PROJECT) {
errorContext.onChange('This project seems to be empty.')
} else if (err.message === errors.BLOCKED_PROJECT) {

2087
yarn.lock

File diff suppressed because it is too large Load diff