From 08c7cfcee7d7b5ab15207e8a4c70170fa615abac Mon Sep 17 00:00:00 2001 From: hccluck Date: Mon, 5 Jan 2026 13:14:26 +0800 Subject: [PATCH] Upgrades to ES2023 and expands API type definitions --- index.d.ts | 2 +- os.d.ts | 31 +++++++++++++++++++++---------- std.d.ts | 15 +++++++++------ tsconfig.json | 6 +++--- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1729b8d..814fee2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/os.d.ts b/os.d.ts index b0a5e70..8f5c127 100644 --- a/os.d.ts +++ b/os.d.ts @@ -63,7 +63,7 @@ declare module "os" { } export const SIGINT: 2; - export const SIGABRT: 6; + export const SIGABRT: 22; export const SIGFPE: 8; export const SIGILL: 4; export const SIGSEGV: 11; @@ -76,19 +76,28 @@ declare module "os" { export const O_RDONLY: 0; export const O_WRONLY: 1; export const O_RDWR: 2; - export const O_CREAT: 64; - export const O_EXCL: 128; + export const O_CREAT: 256; + export const O_EXCL: 1024; export const O_TRUNC: 512; - export const O_APPEND: 1024; + export const O_APPEND: 8; + export const O_TEXT: 16384; + export const O_BINARY: 32768; - export function open(filename: string, flag: number, mode?: unknown): File | -1; + export const S_IFMT: 61440; + export const S_IFIFO: 4096; + export const S_IFCHR: 8192; + export const S_IFDIR: 16384; + export const S_IFBLK: 24576; + export const S_IFREG: 32768; + + export function open( + filename: string, + flag: number, + mode?: unknown + ): File | -1; export function close(file: File): number; export function seek(file: File, offset: number, whence: Seek): number; - export function seek( - file: File, - offset: BigInt, - whence: Seek - ): BigInt; + export function seek(file: File, offset: BigInt, whence: Seek): BigInt; export function read( file: File, buffer: ArrayBuffer, @@ -139,6 +148,8 @@ declare module "os" { export function dup2(oldFile: File, newFile: File): void; export function pipe(): [readFile: File, writeFile: File] | null; export function sleep(delay: number): void; + export function sleepAsync(delay: number): Promise; export function setTimeout(cb: Callback, delay: number): TimeoutHandle; export function clearTimeout(handle: TimeoutHandle): void; + export function now(): number; } diff --git a/std.d.ts b/std.d.ts index 37b70ce..d4ee18a 100644 --- a/std.d.ts +++ b/std.d.ts @@ -1,10 +1,6 @@ declare module "std" { import { File } from "os"; - export interface EvalOptions { - backtrace_barrier?: boolean; - } - export interface ErrorOptions { errorno: Error; } @@ -50,7 +46,14 @@ declare module "std" { } export function exit(n: number): void; - export function evalScript(script: string, options?: EvalOptions): void; + export function evalScript( + script: string, + options?: { backtrace_barrier?: boolean; async?: false } + ): any; + export function evalScript( + script: string, + options?: { backtrace_barrier?: boolean; async?: true } + ): Promise<{ value: any }>; export function loadScript(filename: string): void; export function loadFile(filename: string): void; export function open( @@ -75,7 +78,7 @@ declare module "std" { export function strerror(errorno: Error): string; export function gc(): void; - export function getenv(name: string): any | undefined; + export function getenv(name: string): string | undefined; export function setenv(name: string, value: any): void; export function unsetenv(name: string): void; export function getenviron(): { readonly [key: string]: string }; diff --git a/tsconfig.json b/tsconfig.json index df302a6..5f194ac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "target": "ES2020", - "module": "ES2020", - "lib": ["ES2020"], + "target": "es2023", + "module": "esnext", + "lib": ["ES2023"], "noEmit": true, "strict": true, "noImplicitAny": true,