TypeScript type definitions for Bun's JavaScript runtime APIs

Overview

Bun TypeScript type definitions

Logo

These are the type definitions for Bun's JavaScript runtime APIs.

Installation

Install the bun-types npm package:

# yarn/npm/pnpm work too, "bun-types" is an ordinary npm package
bun add bun-types

Usage

Add this to your tsconfig.json or jsconfig.json:

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "esnext",
    "target": "esnext",
    // "bun-types" is the important part
    "types": ["bun-types"]
  }
}

Contributing

bun-types is generated via ./bundle.ts.

Adding a new file

  1. Add it to ./index.d.ts

How to generate types.d.ts

./bundle.ts merges the types in this folder into a single file.

To run it:

bun generate:package

Generated docs

📚 See here for docs

Comments
  • feat: docs

    feat: docs

    Proof of concept for auto-gen'd docs in markdown, demo here

    • [ ] bun run docs to generate types then generate docs based on types in directory api-docs

    • [ ] Uses typedoc to focus contributor doc energy on high-value content rather than manually annotating + updating types & parameters

    • [ ] Use typedoc.json's publicPath field to set base path for URLs (otherwise falls back to relative prefixed with commit)

    • [ ] duplicative tsconfig.docs.json variant since extends appears to be in-flight

    • [ ] (not sure) optional "images" folder for embedding fun bun logo or gif, ex ![desc](media://bun.png)

    bunidea

    Without publicPath links in repo to specific code appear to have a pathing issue

    chore 
    opened by valgaze 16
  • Is `bun-types` BufferEncoding missing 'base64'?

    Is `bun-types` BufferEncoding missing 'base64'?

    Version

    0.1.6 (bun-types 0.1.5)

    Platform

    Darwin custard 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64

    What steps will reproduce the bug?

    passing base64 to Buffer#toString is a type error, but it works (although missing one padding char... maybe that is a bug) image

    What do you see instead?

    A type error image

    bug need repro 
    opened by alii 5
  • `bun-types`: type declaration of `BufferEncoding` is missing `hex`

    `bun-types`: type declaration of `BufferEncoding` is missing `hex`

    Version

    0.1.4

    Platform

    No response

    What steps will reproduce the bug?

    1. Install bun-types using bun add bun-types -d
    2. Create a tsconfig.json and index.ts with the following content:
    // tsconfig.json
    {
        "compilerOptions": {
            "types": [
                "bun-types"
            ]
        }
    }
    
    // index.ts
    console.log(randomBytes(8).toString('hex'));
    
    1. Execute the code snippet using bun run index.ts:

    How often does it reproduce? Is there a required condition?

    Always

    What is the expected behavior?

    No typescript type error in IDE

    What do you see instead?

    Console output:

    b294075ae26cffa1
    

    The following typescript error:

    Argument of type '"hex"' is not assignable to parameter of type 'BufferEncoding'.ts(2345)

    Additional information

    The implementation exists and works but the type declaration of BufferEncoding is missing hex: https://github.com/oven-sh/bun/blob/f7e9b91701d60f1f1a319acf799871c20aee007a/types/bun/bun.d.ts#L1218-L1227

    bug need repro 
    opened by bogeychan 2
  • `bun-types` is missing `Bun.file().json()` aka `FileBlob.json()`

    `bun-types` is missing `Bun.file().json()` aka `FileBlob.json()`

    Version

    0.1.5

    What steps will reproduce the bug?

    [email protected] used to have .json() but as of 0.1.4 it doesn't.

    i am on bun 0.1.5 and the function continues to work.

    What do you see instead?

    Property 'json' does not exist on type 'FileBlob'. ts(2339)

    bug need repro 
    opened by paperdave 2
  • Update link to pages

    Update link to pages

    Fix typo-- docs link in main README now points to jekyll (rather than markdown/repo hosting strategy)

    @xHyroM is this is a good/stable link? https://oven-sh.github.io/bun-types

    chore 
    opened by valgaze 1
  • feat: add gzipSync, gunzipSync, inflateSync and deflateSync to Bun.* types

    feat: add gzipSync, gunzipSync, inflateSync and deflateSync to Bun.* types

    Additional changes:

    • Updated the generate script on the README as it was wrong: generate -> generate:package
    • Fixes to the Prettier and ESLint setup, refer to this commit for details
    • Added ArrayBuffer as a valid input type for Bun.write
    types:bun types:fs types:fs/promises 
    opened by jhmaster2000 0
  • feat: improvements

    feat: improvements

    TODO

    • [x] ESLint
    • [x] Auto-update version in header
    • [x] Label Sync
    • [x] Labeler
    • [x] Release workflow
    • [x] Add github webhook that points to https://i.bun.sh/github_webhook (cc @Jarred-Sumner)
      • https://github.com/xHyroM/bun-discord-bot/commit/4e747f1fd89b632a82f69df65a388800cd8c8f7a
    • [x] Remove paths.txt - automate it

    Warning I can't push new generated types.d.ts because github throw conflicts (idk why)

    Added:

    feat: improvements - feat: added eslint - feat: update version in header.txt - fix(url): remove unused import ClientRequestArgs

    feat: add labeler and labels fix: add header to labeler, cleanup labels feat: remove paths.txt

    types:url types:crypto types:globals chore 
    opened by xHyroM 0
Releases(v0.1.10)
A script that combines a folder of SVG files into a single sprites file and generates type definitions for safe usage.

remix-sprites-example A script that combines a folder of .svg files into a single sprites.svg file and type definitions for safe usage. Technical Over

Nicolas Kleiderer 19 Nov 9, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Simple, lightweight at-runtime type checking functions, with full TypeScript support

pheno Simple, lightweight at-runtime type checking functions, with full TypeScript support Features Full TypeScript integration: TypeScript understand

Lily Scott 127 Sep 5, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

?? HypeScript Introduction This is a simplified implementation of TypeScript's type system that's written in TypeScript's type annotations. This means

Ronen Amiel 1.8k Dec 20, 2022
Runtime type checking in pure javascript.

Install npm install function-schema Usage import { signature } from 'function-schema'; const myFunction = signature(...ParamTypeChecks)(ReturnValueCh

Jeysson Guevara 3 May 30, 2022
Zero runtime type-safe CSS in the same file as components

macaron comptime-css is now called macaron! macaron is a zero-runtime and type-safe CSS-in-JS library made with performance in mind Powered by vanilla

Mokshit Jain 205 Jan 4, 2023
Style definitions for nice terminal layouts 👄

blipgloss Style definitions for nice terminal layouts. Powered by lipgloss and bun:ffi. Install bun add blipgloss Usage Blipgloss takes an expressive,

Robert Soriano 51 Dec 31, 2022
Combine type and value imports using Typescript 4.5 type modifier syntax

type-import-codemod Combines your type and value imports together into a single statement, using Typescript 4.5's type modifier syntax. Before: import

Ian VanSchooten 4 Sep 29, 2022
A type programming language which compiles to and interops with type-level TypeScript

Prakaar Prakaar (hindi for "type") is a type programming language which compiles to and interops with type-level TypeScript. Prakaar itself is also a

Devansh Jethmalani 17 Sep 21, 2022
A transpiler from golang's type to typescript's type for collaboration between frontend & backend.

go2type go2type.vercel.app (backup site) A typescript transpiler that convert golang's type to typescript's type. Help front-end developer to work fas

Oanakiaja 8 Sep 26, 2022
End-to-End type safety for REST APIs written in Fastify. Only problem is you have to explicity export and register route handlers. LOL

Chino intelligence in japaneese End-to-End type safety for REST APIs written in Fastify. Only problem is you have to explicity export and register rou

sambit sahoo 2 Sep 12, 2022
👩‍🎤 Headless, type-safe, UI components for the next generation Web3.Storage APIs.

Headless, type-safe, UI components for the next generation Web3.Storage APIs. Documentation beta.ui.web3.storage Examples React Sign up / Sign in Sing

Web3 Storage 47 Dec 22, 2022
Runtime object parsing and validation with static TypeScript typing.

TypeParse Runtime object transformation, parsing and validation with inferred static TypeScript typing. Install Using npm npm install typeparse Using

Kenneth Herrera 4 May 5, 2022
Type predicate functions for checking if a value is of a specific type or asserting that it is.

As-Is Description As-Is contains two modules. Is - Type predicates for checking values are of certain types. As - Asserting values are of a certain ty

Declan Fitzpatrick 8 Feb 10, 2022
🧬 A type builder for pagination with prisma and type-graphql.

?? Prisma TypeGraphql Pagination Prisma TypeGraphql Pagination builds prisma pagination types for type-graphql. import { ... } from 'type-graphql'

Arthur Fiorette 2 Apr 21, 2022
100% type-safe query builder for node-postgres :: Generated types, call any function, tree-shakable, implicit type casts, and more

⚠️ This library is currently in alpha. Contributors wanted! tusken Postgres client from a galaxy far, far away. your database is the source-of-truth f

alloc 54 Dec 29, 2022