Specify the unknown type (#965)

This commit is contained in:
woxtu
2022-11-22 03:13:57 +09:00
committed by GitHub
parent cb05a9b067
commit 0d79d31b96
2 changed files with 9 additions and 11 deletions

View File

@@ -77,7 +77,7 @@ export class PyodideRuntime extends Runtime {
logger.info('pyodide loaded and initialized');
}
run(code: string) {
run(code: string): unknown {
return this.interpreter.runPython(code);
}

View File

@@ -55,7 +55,7 @@ export abstract class Runtime extends Object {
* (asynchronously) which can call its own API behind the scenes.
* Python exceptions are turned into JS exceptions.
* */
abstract run(code: string);
abstract run(code: string): unknown;
/**
* Same as run, but Python exceptions are not propagated: instead, they
@@ -64,16 +64,14 @@ export abstract class Runtime extends Object {
* This is a bad API and should be killed/refactored/changed eventually,
* but for now we have code which relies on it.
* */
runButDontRaise(code: string) {
let result
try{
result = this.run(code)
runButDontRaise(code: string): unknown {
let result: unknown;
try {
result = this.run(code);
} catch (error: unknown) {
logger.error('Error:', error);
}
catch (err){
const error = err as Error
logger.error('Error:', error)
}
return result
return result;
}
/**