{"id":30615404,"url":"https://github.com/alii/bun-types-no-globals","last_synced_at":"2026-05-18T02:12:41.267Z","repository":{"id":311226437,"uuid":"1042526621","full_name":"alii/bun-types-no-globals","owner":"alii","description":"Bun types with no globals to prevent polluting your environment","archived":false,"fork":false,"pushed_at":"2026-05-14T00:41:35.000Z","size":1332,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T02:38:38.509Z","etag":null,"topics":["bun","runtime","type-definitons","types","typescript","typings"],"latest_commit_sha":null,"homepage":"https://bun.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-22T06:47:55.000Z","updated_at":"2026-05-14T00:41:39.000Z","dependencies_parsed_at":"2026-02-28T03:05:46.608Z","dependency_job_id":null,"html_url":"https://github.com/alii/bun-types-no-globals","commit_stats":null,"previous_names":["alii/bun-types-no-globals"],"tags_count":270,"template":false,"template_full_name":null,"purl":"pkg:github/alii/bun-types-no-globals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fbun-types-no-globals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fbun-types-no-globals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fbun-types-no-globals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fbun-types-no-globals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alii","download_url":"https://codeload.github.com/alii/bun-types-no-globals/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fbun-types-no-globals/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33162448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","runtime","type-definitons","types","typescript","typings"],"created_at":"2025-08-30T08:02:22.307Z","updated_at":"2026-05-18T02:12:41.221Z","avatar_url":"https://github.com/alii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://bun.com/logo.png\" height=\"36\" /\u003e\n\n# bun-types-no-globals\n\nTypeScript type definitions for Bun's APIs without global namespace pollution. This package provides clean, isolated Bun types that won't interfere with other environments or type systems.\n\n\u003e **Note:** This package is for advanced use cases only. You are probably looking for [`@types/bun`](https://www.npmjs.com/package/@types/bun) instead.\n\n## Why does this exist?\n\nWhen building universal tools or libraries that support multiple runtimes (Node.js, Bun, browsers, etc.), importing `@types/bun` causes problems:\n\n- **Global type pollution**: Regular Bun types modify global interfaces and add global variables that conflict with Node.js or browser types\n- **Transitive type leakage**: If your library uses `@types/bun`, everyone who installs your library gets Bun's global types too - even if they're not using Bun\n- **Multi-bundler compatibility issues**: Tools like [unplugin](https://github.com/unjs/unplugin) that support webpack, Vite, Rollup, esbuild, AND Bun can't use regular Bun types without forcing them on all users\n\nThis package solves these issues by providing Bun's type definitions in an isolated, non-global way.\n\n## Common Use Cases\n\n### 🔧 Multi-Runtime Libraries\n\nLibraries that work across Node.js, Bun, and browsers can safely import Bun-specific APIs without breaking TypeScript for other runtimes:\n\n```ts\nimport type { BunFile } from 'bun';\n\nexport function processFile(file: BunFile | Buffer) {\n\t// Implementation that works with both Bun and Node.js\n}\n```\n\n### 🛠️ Build Tool Plugins\n\nBuild tools and bundler plugins (like unplugin) can add Bun support without forcing Bun types on webpack, Vite, or Rollup users:\n\n```ts\nimport type { BunPlugin } from 'bun';\n\nexport function createPlugin(): BunPlugin | WebpackPlugin | VitePlugin {\n\t// Plugin implementation\n}\n```\n\n### 🛠️ [Re-\\]declaring the Bun namespace\n\nSometimes you'll still want the Bun namespace to globally exist - this is most helpful in situations where actually including a runtime import from `bun` is more inconvenient than using the Bun namespace itself. You can tell TypeScript about the namespace by including this code somewhere in your program:\n\n```ts\nimport * as BunModule from 'bun';\n\ndeclare global {\n\texport import Bun = BunModule;\n}\n```\n\nI wrote a little about the above syntax [on my blog about Ambient Declarations](https://alistair.sh/ambient-declarations).\n\n## Usage\n\nWe recommend you require these types with a triple slash reference anywhere in your program\n\n```ts\n/// \u003creference types=\"bun-types-no-globals/lib/index.d.ts\" /\u003e\n```\n\nThe **alternative** is to include it in your tsconfig.json types array\n\n```jsonc\n{\n\t\"compilerOptions\": {\n\t\t\"types\": [\"bun-types-no-globals\"],\n\t},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falii%2Fbun-types-no-globals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falii%2Fbun-types-no-globals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falii%2Fbun-types-no-globals/lists"}