import { ZlibCompressionOptions } from "bun"; import { expectAssignable, expectType } from "tsd"; import Bun, { fs, fsPromises } from "./exports"; // FileBlob expectType>(Bun.file("index.test-d.ts").stream()); expectType>(Bun.file("index.test-d.ts").arrayBuffer()); expectType>(Bun.file("index.test-d.ts").text()); expectType(Bun.file("index.test-d.ts").size); expectType(Bun.file("index.test-d.ts").type); // Hash expectType(new Bun.MD4().update("test").digest("hex")); expectType(new Bun.MD5().update("test").digest("hex")); expectType(new Bun.SHA1().update("test").digest("hex")); expectType(new Bun.SHA224().update("test").digest("hex")); expectType(new Bun.SHA256().update("test").digest("hex")); expectType(new Bun.SHA384().update("test").digest("hex")); expectType(new Bun.SHA512().update("test").digest("hex")); expectType(new Bun.SHA512_256().update("test").digest("hex")); // Zlib Functions expectType(Bun.deflateSync(new Uint8Array(128))); expectType(Bun.gzipSync(new Uint8Array(128))); expectType( Bun.deflateSync(new Uint8Array(128), { level: -1, memLevel: 8, strategy: 0, windowBits: 15, }), ); expectType( Bun.gzipSync(new Uint8Array(128), { level: 9, memLevel: 6, windowBits: 27 }), ); expectType(Bun.inflateSync(new Uint8Array(64))); // Pretend this is DEFLATE compressed data expectType(Bun.gunzipSync(new Uint8Array(64))); // Pretend this is GZIP compressed data expectAssignable({ windowBits: -11 }); // Other expectType>(Bun.write("test.json", "lol")); expectType>(Bun.write("test.json", new ArrayBuffer(32))); expectType(Bun.pathToFileURL("/foo/bar.txt")); expectType(Bun.fileURLToPath(new URL("file:///foo/bar.txt"))); // Testing ../fs.d.ts expectType( fs.readFileSync("./index.d.ts", { encoding: "utf-8" }).toString(), ); expectType(fs.existsSync("./index.d.ts")); expectType(fs.accessSync("./index.d.ts")); expectType(fs.appendFileSync("./index.d.ts", "test")); expectType(fs.mkdirSync("./index.d.ts")); // Testing ^promises.d.ts expectType( (await fsPromises.readFile("./index.d.ts", { encoding: "utf-8" })).toString(), ); expectType>(fsPromises.access("./index.d.ts")); expectType>(fsPromises.appendFile("./index.d.ts", "test")); expectType>(fsPromises.mkdir("./index.d.ts")); Bun.env; Bun.version; setImmediate; clearImmediate; setInterval; clearInterval; setTimeout; clearTimeout; const arg = new AbortSignal(); arg; const e = new CustomEvent("asdf"); console.log(e); exports; module.exports; global.AbortController; global.Bun; const er = new DOMException(); er.name; er.HIERARCHY_REQUEST_ERR; new Request(new Request("https://example.com"), {}); new Request("", { method: "POST" }); Bun.sleepSync(1); // sleep for 1 ms (not recommended) await Bun.sleep(1); // sleep for 1 ms (recommended) Blob; WebSocket;