Repository navigation
Conversation
Each entry of Bun.embeddedFiles is a Blob whose `name` is the name of the embedded file. The declaration was ReadonlyArray<Blob>, and Blob has no `name`, so `blob.name` in the two samples of docs/compiler/executables.mdx was TS2339.
StatusHow it was reproduced: Pull request: #48483 |
|
Updated 10:51 AM PT - Nov 10th, 2026
✅ @robobun, your commit e907ecd6e80857cfb2d66d2d891883a90157ba4d passed in 🧪 To try this PR locally: bunx bun-pr 48483That installs a local version of the PR into your bun-48483 --bun |
|
No actionable comments were generated in the recent review. Walkthrough
ChangesEmbedded file name type
Possibly related PRs
Suggested reviewers: Merge Risk:
|
Problem
blob.nameon an entry ofBun.embeddedFilesiserror TS2339: Property 'name' does not exist on type 'Blob'. Two samples ofdocs/compiler/executables.mdxread it (lines 1016 and 1042).ReadonlyArray<Blob>(packages/bun-types/bun.d.ts:5198).Blobdeclares noname.Fix
ReadonlyArray<Blob & { readonly name: string }>, and show that type on the page.bun build --compile(canary 98cda0d), each entry is aBlob, not aFile, andtypeof blob.nameis"string".template_blobsets the name from the embedded path (src/runtime/api/standalone_graph_jsc.rs:64). Both samples run as written.test/integration/bun-types/fixture/bun.ts(the new lines report TS2339 and TS2578 with the declaration of main).bun test test/integration/bun-types/bun-types.test.ts: 30 pass.Background
Bun.embeddedFileslists the files that a standalone executable embeds, for example an import with{ type: "file" }.Blobhas no name in the types, andnew Blob(["x"]).nameisundefinedat runtime.BunFile: it promiseswriter()andunlink(), which throw for an embedded file, andstat(), which resolves toundefined. ConsideredFile:blob instanceof Fileisfalse.Downsides
Blobno longer fits where an entry is expected:const one: (typeof Bun.embeddedFiles)[number] = new Blob(["x"])is TS2322. 3 of 15 usage shapes that compile on main fail. One is a// @ts-expect-erroraboveblob.name, which is now unused.blob.name = "x"works at runtime. It is TS2540 now, and TS2339 on main.builtin_sources.bingrows 6 bytes and the package tarball 82 bytes.Notes
Origin. The type check of the docs code blocks in #48479 found the two samples. With this change, that check reports nothing for the two samples and for the type listing of the page. If #48479 lands first, this pull request also removes those three entries of
docs/compiler/executables.mdxfromdocs-samples.inventory.json.Runtime probe (canary 1.4.4-canary.1+98cda0d8b, Linux x64).
index.tsimports./icon.png,./data.jsonand./template.htmlwith{ type: "file" }, then prints each entry ofembeddedFiles. Built withbun build --compile ./index.ts --outfile ./app:Run with
bun index.ts, the array is empty. On an entry,writer()andunlink()throwERR_INVALID_ARG_TYPE("Cannot write to a Blob backed by bytes, which are always read-only"),await stat()isundefined, andawait exists()istrue. The second sample of the page (static routes from the embedded files) answers 200 for/favicon.ico,/logo.pngand/styles.cssand 404 for another path.Why
nameis always a string.template_blobsets the blob's name todisplay_name(), the embedded path without/$bunfs/root/. Thenamegetter ofBlobreturns that string (src/runtime/webcore/Blob.rs:1753).readonly.BunFile.nameand theFile.nameof the web platform are read-only in the types. The setter ofBlob.prototype.nameexists at runtime today. #32434 proposes to movenametoFile.prototype.Measurements (TypeScript 6.0.2, the
bun inittsconfig, main at 89452d2)docs/compiler/executables.mdx: TS2339 each on main, 0 diagnostics with this change. The type listing of the page wasembeddedFiles: ReadonlyArray<Blob>;, which is TS2689 as a program. It is adeclare constnow, 0 diagnostics.Bun.embeddedFiles): 15 compile on main, 3 of them fail with this change (the unused@ts-expect-error, a plainBlobassigned to the element type, a plainBlobpushed into a copy of the array). 4 that fail on main compile with this change.bun.d.tswithout comments: 85,099 to 85,127 bytes. Its zstd frame inbuiltin_sources.bin: 16,805 to 16,811 bytes (the parameters ofsrc/codegen/builtins-manifest.ts).bun pm packofpackages/bun-types: 82 bytes more (1,522,674 to 1,522,756, measured at 2596ac5).lib.dom: covered by thechecks with lib.dom.d.tscase of the test.no test proof · iteration 0 · no src or test change; test-proof not applicable