Skip to content

@types/bun still conflicts with @types/node #8761

Description

@lgarron

What version of Bun is running?

1.0.25+a8ff7be64

What platform is your computer?

Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

mkdir /tmp/bun-node-types && cd /tmp/bun-node-types
bun init --yes
bun add @types/node @types/bun typescript
echo "{}" > tsconfig.json # Remove `skipLibCheck`
bun x tsc

What is the expected behavior?

TypeScript runs successfully.

What do you see instead?

node_modules/typescript/lib/lib.dom.d.ts:8138:11 - error TS2430: Interface 'EventSource' incorrectly extends interface 'Bun.EventSource'.
  Types of property 'onerror' are incompatible.
    Type '(this: EventSource, ev: Event) => any' is not assignable to type '(this: Bun.EventSource, ev: Event) => any'.
      The 'this' types of each signature are incompatible.
        Type 'Bun.EventSource' is not assignable to type 'EventSource'.
          Types of property 'onmessage' are incompatible.
            Type '(this: Bun.EventSource, ev: Bun.MessageEvent<any>) => any' is not assignable to type '(this: EventSource, ev: MessageEvent<any>) => any'.
              Types of parameters 'ev' and 'ev' are incompatible.
                Type 'MessageEvent<any>' is not assignable to type 'Bun.MessageEvent<any>'.
                  Types of property 'ports' are incompatible.
                    Type 'readonly MessagePort[]' is not assignable to type 'readonly import("worker_threads").MessagePort[]'.
                      Type 'MessagePort' is missing the following properties from type 'MessagePort': ref, unref, addListener, emit, and 13 more.

8138 interface EventSource extends EventTarget {
               ~~~~~~~~~~~

node_modules/typescript/lib/lib.dom.d.ts:15414:11 - error TS2430: Interface 'MessageEvent<T>' incorrectly extends interface 'Bun.MessageEvent<T>'.
  Types of property 'ports' are incompatible.
    Type 'readonly MessagePort[]' is not assignable to type 'readonly import("worker_threads").MessagePort[]'.

15414 interface MessageEvent<T = any> extends Event {
                ~~~~~~~~~~~~

node_modules/typescript/lib/lib.dom.d.ts:25362:11 - error TS2430: Interface 'WebSocket' incorrectly extends interface 'import("/private/tmp/bun-node-types/node_modules/@types/ws/index").WebSocket'.
  Types of property 'binaryType' are incompatible.
    Type 'BinaryType' is not assignable to type '"arraybuffer" | "nodebuffer" | "fragments"'.
      Type '"blob"' is not assignable to type '"arraybuffer" | "nodebuffer" | "fragments"'.

25362 interface WebSocket extends EventTarget {
                ~~~~~~~~~


Found 3 errors in the same file, starting at: node_modules/typescript/lib/lib.dom.d.ts:8138

Additional information

Also see:

This prevents me from using @types/bun in projects where @types/node is also needed. When I try to use @types/bun in cubing.js, I get additional conflicts:

node_modules/@types/node/module.d.ts:283:13 - error TS2687: All declarations of 'dirname' must have identical modifiers.

283             dirname: string;
                ~~~~~~~

node_modules/@types/node/module.d.ts:289:13 - error TS2687: All declarations of 'filename' must have identical modifiers.

289             filename: string;
                ~~~~~~~~

node_modules/bun-types/types.d.ts:601:12 - error TS2687: All declarations of 'dirname' must have identical modifiers.

601   readonly dirname: string;
               ~~~~~~~

node_modules/bun-types/types.d.ts:604:12 - error TS2687: All declarations of 'filename' must have identical modifiers.

604   readonly filename: string;
               ~~~~~~~~

node_modules/bun-types/types.d.ts:1036:20 - error TS2694: Namespace 'WebSocket' has no exported member 'WebSocket'.

1036     : import("ws").WebSocket;
                        ~~~~~~~~~

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtypesAn issue with TypeScript types

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions