diff options
author | 2023-02-02 17:29:10 -0800 | |
---|---|---|
committer | 2023-02-02 17:29:10 -0800 | |
commit | 742368f03add1a2d7bc22582ea693670145d79f3 (patch) | |
tree | 38737629959b9583ee6f1ea4bd7fcde8027b4ff2 | |
parent | 242dcea2fe44b4385037850da56b30f23cdd8b15 (diff) | |
download | bun-742368f03add1a2d7bc22582ea693670145d79f3.tar.gz bun-742368f03add1a2d7bc22582ea693670145d79f3.tar.zst bun-742368f03add1a2d7bc22582ea693670145d79f3.zip |
Update/fix types (#1955)
* WIP
* Update types
* Spacing
---------
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
-rw-r--r-- | packages/bun-types/globals.d.ts | 24 | ||||
-rw-r--r-- | packages/bun-types/readline.d.ts | 23 | ||||
-rw-r--r-- | packages/bun-types/readline/promises.d.ts | 7 | ||||
-rw-r--r-- | packages/bun-types/tests/env.test-d.ts | 7 |
4 files changed, 33 insertions, 28 deletions
diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index c83d29f5c..1c91d6b2f 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -832,22 +832,21 @@ interface RequestInit { * Enable or disable HTTP request timeout */ timeout?: boolean; - } interface FetchRequestInit extends RequestInit { - /** + /** * Log the raw HTTP request & response to stdout. This API may be * removed in a future version of Bun without notice. * This is a custom property that is not part of the Fetch API specification. * It exists mostly as a debugging tool */ - verbose?: boolean, - /** - * Override http_proxy or HTTPS_PROXY - * This is a custom property that is not part of the Fetch API specification. - */ - proxy?: string + verbose?: boolean; + /** + * Override http_proxy or HTTPS_PROXY + * This is a custom property that is not part of the Fetch API specification. + */ + proxy?: string; } /** @@ -1254,8 +1253,8 @@ declare function clearTimeout(id?: number): void; * */ declare function fetch( - url: string, - init?: FetchRequestInit + url: string | URL, + init?: FetchRequestInit, ): Promise<Response>; /** @@ -1269,10 +1268,7 @@ declare function fetch( * */ // tslint:disable-next-line:unified-signatures -declare function fetch( - request: Request, - init?: RequestInit -): Promise<Response>; +declare function fetch(request: Request, init?: RequestInit): Promise<Response>; declare function queueMicrotask(callback: (...args: any[]) => void): void; /** diff --git a/packages/bun-types/readline.d.ts b/packages/bun-types/readline.d.ts index d0ef34741..3125e992b 100644 --- a/packages/bun-types/readline.d.ts +++ b/packages/bun-types/readline.d.ts @@ -33,6 +33,7 @@ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js) */ declare module "readline" { + import { Readable, Writable } from "node:stream"; import { Abortable, EventEmitter } from "node:events"; import * as promises from "node:readline/promises"; @@ -103,8 +104,8 @@ declare module "readline" { * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface */ protected constructor( - input: ReadableStream, - output?: WritableStream, + input: Readable, + output?: Writable, completer?: Completer | AsyncCompleter, terminal?: boolean, ); @@ -344,8 +345,8 @@ declare module "readline" { ) => void; export type CompleterResult = [string[], string]; export interface ReadLineOptions { - input: ReadableStream; - output?: WritableStream | undefined; + input: Readable; + output?: Writable | undefined; completer?: Completer | AsyncCompleter | undefined; terminal?: boolean | undefined; /** @@ -405,8 +406,8 @@ declare module "readline" { * @since v0.1.98 */ export function createInterface( - input: ReadableStream, - output?: WritableStream, + input: Readable, + output?: Writable, completer?: Completer | AsyncCompleter, terminal?: boolean, ): Interface; @@ -533,7 +534,7 @@ declare module "readline" { * @since v0.7.7 */ export function emitKeypressEvents( - stream: ReadableStream, + stream: Readable, readlineInterface?: Interface, ): void; export type Direction = -1 | 0 | 1; @@ -549,7 +550,7 @@ declare module "readline" { * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. */ export function clearLine( - stream: WritableStream, + stream: Writable, dir: Direction, callback?: () => void, ): boolean; @@ -561,7 +562,7 @@ declare module "readline" { * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. */ export function clearScreenDown( - stream: WritableStream, + stream: Writable, callback?: () => void, ): boolean; /** @@ -572,7 +573,7 @@ declare module "readline" { * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. */ export function cursorTo( - stream: WritableStream, + stream: Writable, x: number, y?: number, callback?: () => void, @@ -688,7 +689,7 @@ declare module "readline" { * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. */ export function moveCursor( - stream: WritableStream, + stream: Writable, dx: number, dy: number, callback?: () => void, diff --git a/packages/bun-types/readline/promises.d.ts b/packages/bun-types/readline/promises.d.ts index 160dd41af..5e5df3d3f 100644 --- a/packages/bun-types/readline/promises.d.ts +++ b/packages/bun-types/readline/promises.d.ts @@ -5,6 +5,7 @@ * @since v17.0.0 */ declare module "readline/promises" { + import { Readable, Writable } from "node:stream"; import { Interface as _Interface, ReadLineOptions, @@ -56,7 +57,7 @@ declare module "readline/promises" { /** * @param stream A TTY stream. */ - constructor(stream: WritableStream, options?: { autoCommit?: boolean }); + constructor(stream: Writable, options?: { autoCommit?: boolean }); /** * The `rl.clearLine()` method adds to the internal list of pending action an action that clears current line of the associated `stream` in a specified direction identified by `dir`. * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor. @@ -137,8 +138,8 @@ declare module "readline/promises" { * ``` */ function createInterface( - input: ReadableStream, - output?: WritableStream, + input: Readable, + output?: Writable, completer?: Completer | AsyncCompleter, terminal?: boolean, ): Interface; diff --git a/packages/bun-types/tests/env.test-d.ts b/packages/bun-types/tests/env.test-d.ts index 805aa4126..073caabfe 100644 --- a/packages/bun-types/tests/env.test-d.ts +++ b/packages/bun-types/tests/env.test-d.ts @@ -11,3 +11,10 @@ declare global { expectType<"WHATEVER">(process.env.WHATEVER); export {}; +new Bun.Transpiler({ + macros: { + "react-relay": { + graphql: "bun-macro-relay/bun-macro-relay.tsx", + }, + }, +}); |