From e907ecd6e80857cfb2d66d2d891883a90157ba4d Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Mon, 9 Nov 2026 22:07:01 +0000 Subject: [PATCH] bun-types: declare the name of each Bun.embeddedFiles entry Each entry of Bun.embeddedFiles is a Blob whose `name` is the name of the embedded file. The declaration was ReadonlyArray, and Blob has no `name`, so `blob.name` in the two samples of docs/compiler/executables.mdx was TS2339. --- docs/compiler/executables.mdx | 2 +- packages/bun-types/bun.d.ts | 4 +++- test/integration/bun-types/fixture/bun.ts | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/compiler/executables.mdx b/docs/compiler/executables.mdx index 1abdf1bc9b47..74dc40c9e4c5 100644 --- a/docs/compiler/executables.mdx +++ b/docs/compiler/executables.mdx @@ -1024,7 +1024,7 @@ for (const blob of embeddedFiles) { Each item in `Bun.embeddedFiles` is a `Blob` with a `name` property: ```ts -embeddedFiles: ReadonlyArray; +declare const embeddedFiles: ReadonlyArray; ``` Use it to serve every embedded asset through static routes: diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 7ff2db50d2b1..438783d2c4c5 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -5193,9 +5193,11 @@ declare module "bun" { /** * A list of files embedded into the standalone executable, lexicographically sorted by name. * + * The `name` of each file is its name in the executable, such as `"icon-a1b2c3d4.png"`. + * * If the process is not a standalone executable, this array is empty. */ - const embeddedFiles: ReadonlyArray; + const embeddedFiles: ReadonlyArray; /** * `true` when the current process is a standalone executable produced by diff --git a/test/integration/bun-types/fixture/bun.ts b/test/integration/bun-types/fixture/bun.ts index f33b1b135a04..cfd8b6f1a6ae 100644 --- a/test/integration/bun-types/fixture/bun.ts +++ b/test/integration/bun-types/fixture/bun.ts @@ -34,6 +34,14 @@ import * as tsd from "./utilities"; tsd.expectType(f); tsd.expectType(f); } +{ + for (const file of Bun.embeddedFiles) { + tsd.expectType(file.name).is(); + tsd.expectType(file).extends(); + } + // @ts-expect-error - a Blob that is not an embedded file has no name + const notEmbedded: (typeof Bun.embeddedFiles)[number] = new Blob([]); +} { Bun.spawn(["anything"], { env: process.env,