Files
bun.sh/packages/bun-types
Dylan Conway 4792abdb7f Implement toMatchSnapshot() (#2294)
* buggy snapshot

* error output for failed snapshot

* missing first

* hints

* open dir once, better cleanup

* update flag

* truncate on update

* object and class snapshot formatting

* array formatting

* no function name, single item is empty array

* string objects, maps, sets, promise

* avoid using invalid memory

* handle number objects

* handle extending `Number`

* boolean objects

* snapshot tests and test updates

* snapshot format for buffers

* safer snapshot parsing

* property matchers setup

* strings and tests

* generate classes with empty prototype

* optional `propertyMatchers` parameter

* new test folder structure

* strings.eqlLong

* globalObject.throwPretty() and expect.any tests

* add updateSnapshot flag to help

* move snapshot format out of `printErrorlikeObject`

* empty object snapshot format

* separate typed array, remove trailing comma

* use `isCell`, object trailing commas

* handle unicode

* todo for primitive constructors

* switch to `JSC.Node.Syscall.open` and `JSC.Maybe`

* use js parser for snapshot files

* deinit ast, log parse error

* copy/paste most of `exports.ZigConsoleClient`

* remove snapshot option

* remove ordered properties option

* remove snapshot format option from `exports.zig`

* remove extra newlines

* change mode

* update test runner output

* escape backticks faster

* `bunx jest` in temp dir

* remove buffered writer

* add `toMatchSnapshot` to types

* cleanup, switch to `pread`

* cli `--update` flag

* `--update-snapshots`

* remove string object format
2023-03-14 16:50:59 -07:00
..
2023-02-02 17:29:10 -08:00
2023-02-07 04:47:36 -08:00
2022-12-06 18:48:02 -08:00
2023-02-06 21:36:36 -08:00
2023-01-11 14:56:41 -08:00
2023-01-11 14:56:41 -08:00
2023-01-11 14:56:41 -08:00
2023-02-06 21:36:36 -08:00
2023-03-03 14:24:12 -08:00
2022-12-13 20:47:51 -08:00
2023-03-03 14:24:12 -08:00
2023-02-02 17:29:10 -08:00
2023-02-22 17:45:22 -08:00
2023-01-11 14:56:41 -08:00
2023-02-06 21:36:36 -08:00
2023-01-11 14:56:41 -08:00
2023-02-06 21:36:36 -08:00
2023-01-11 14:56:41 -08:00

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",
    "moduleResolution": "Node",
    // "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 build

Generated docs

📚 See here for docs