js2ts: util.ts 분리

This commit is contained in:
Hide_D committed 2021-08-21 20:45:10 +09:00
1 parent 1496fbe0b7
commit 6cc37dedd2
16 files changed
+56 -86

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
import { Nullable } from "./Nullable";
type ErrType<T> = { new(msg?: string): T }
export function unwrap_err<T, ErrT extends Error>(result: Nullable<T>, errType: ErrType<ErrT>, errMsg?: string): T {
if (result === null || result === undefined) {
throw new errType(errMsg);
}
return result;
}