Skip to content

Commit

Permalink
Better types (#7670)
Browse files Browse the repository at this point in the history
* Rewrite bun-types to include @types/node

* Incorporate new commits

* Update bun.lockb

* [autofix.ci] apply automated fixes

* Update readme, add back webkit

* Updates

* BunJS -> Bun

* Switch init to @types/bun

* [autofix.ci] apply automated fixes

* Tweaks

* Revert docs changes

* Fix bugs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
colinhacks and autofix-ci[bot] authored Dec 18, 2023
1 parent a1a4178 commit 31c17a1
Show file tree
Hide file tree
Showing 107 changed files with 3,117 additions and 33,592 deletions.
12 changes: 12 additions & 0 deletions packages/bun-types/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
"plugin:@definitelytyped/all",
],
rules: {
"no-var": "off", // global variables
Expand All @@ -20,5 +21,16 @@ module.exports = {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-misused-new": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/no-empty-interface": "off",
"@definitelytyped/no-single-declare-module": "off",
"@definitelytyped/no-self-import": "off",
"@definitelytyped/no-unnecessary-generics": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-invalid-void-type": "off",
"@definitelytyped/no-single-element-tuple-type": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/unbound-method": "off",
},
};
24 changes: 6 additions & 18 deletions packages/bun-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,19 @@ These are the type definitions for Bun's JavaScript runtime APIs.

# Installation

Install the `bun-types` npm package:
Install the `@types/bun` npm package:

```bash
# yarn/npm/pnpm work too, "bun-types" is an ordinary npm package
bun add -d bun-types
# yarn/npm/pnpm work too
# @types/bun is an ordinary npm package
bun add -D @types/bun
```

# Usage

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

```jsonc-diff
{
"compilerOptions": {
+ "types": ["bun-types"]
// other options...
}
// other options...
}
```
That's it! VS Code and TypeScript automatically load `@types/*` packages into your project, so the `Bun` global and all `bun:*` modules should be available immediately.

# Contributing

`bun-types` is generated via [./scripts/bundle.ts](./scripts/bundle.ts).
The `@types/bun` package is a shim that loads `bun-types`. The `bun-types` package lives in the Bun repo under `packages/bun-types`. It is generated via [./scripts/bundle.ts](./scripts/bundle.ts).

To add a new file, add it under `packages/bun-types`. Then add a [triple-slash directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) pointing to it inside [./index.d.ts](./index.d.ts).

Expand Down
Loading

0 comments on commit 31c17a1

Please sign in to comment.