mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Fix type errors due to unknow type in try catch
This commit is contained in:
parent
b5cc6e7662
commit
c6dfab9e67
6 changed files with 17 additions and 9 deletions
|
|
@ -16,7 +16,8 @@ const _extract = (script?: vm.Script): Record<string, any> => {
|
|||
const _syntaxValidation = (cfg: string) => {
|
||||
try {
|
||||
return new vm.Script(cfg, {filename: '.hyper.js', displayErrors: true});
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {name: string};
|
||||
notify(`Error loading config: ${err.name}`, `${err}`, {error: err});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -296,7 +296,8 @@ function requirePlugins(): any[] {
|
|||
console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
|
||||
|
||||
return mod;
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string; message: string};
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ export default class Session extends EventEmitter {
|
|||
|
||||
try {
|
||||
this.pty = spawn(shell, shellArgs, options);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {message: string};
|
||||
if (/is not a function/.test(err.message)) {
|
||||
throw createNodePtyError();
|
||||
} else {
|
||||
|
|
@ -215,7 +216,8 @@ fallback to default shell config: ${JSON.stringify(defaultShellConfig, undefined
|
|||
if (this.pty) {
|
||||
try {
|
||||
this.pty.resize(cols, rows);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
console.error(err.stack);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -227,7 +229,8 @@ fallback to default shell config: ${JSON.stringify(defaultShellConfig, undefined
|
|||
if (this.pty) {
|
||||
try {
|
||||
this.pty.kill();
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {stack: any};
|
||||
console.error('exit error', err.stack);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ const addSymlink = async (silent: boolean) => {
|
|||
}
|
||||
}
|
||||
await symlink(cliScriptPath, cliLinkPath);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string};
|
||||
// 'EINVAL' is returned by readlink,
|
||||
// 'EEXIST' is returned by symlink
|
||||
let error =
|
||||
|
|
@ -61,7 +62,7 @@ sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`,
|
|||
await sudoExec(`ln -sf "${cliScriptPath}" "${cliLinkPath}"`, {name: 'Hyper'});
|
||||
return;
|
||||
} catch (_error) {
|
||||
error = _error[0];
|
||||
error = (_error as any[])[0];
|
||||
}
|
||||
} else if (result.response === 1) {
|
||||
clipboard.writeText(`sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
|||
const getFileContents = memoize(() => {
|
||||
try {
|
||||
return fs.readFileSync(fileName, 'utf8');
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
const err = _err as {code: string};
|
||||
if (err.code !== 'ENOENT') {
|
||||
// ENOENT === !exists()
|
||||
throw err;
|
||||
|
|
|
|||
|
|
@ -352,7 +352,8 @@ export default class Term extends React.PureComponent<TermProps> {
|
|||
.forEach((option) => {
|
||||
try {
|
||||
this.term.setOption(option, nextTermOptions[option]);
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
const e = _e as {message: string};
|
||||
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
|
||||
// Ignore this because the char atlas will also be changed
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue