drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.52k stars 643 forks source link

[BUG]: Bun-types as peerdepency overrides nodejs global types in monorepos #1376

Open Makisuo opened 1 year ago

Makisuo commented 1 year ago

What version of drizzle-orm are you using?

0.28.6

What version of drizzle-kit are you using?

0.5.1

Describe the Bug

Basically, since bun-types is a peer-dependency of drizzle-orm, it somehow overrides all my global types like window, navigator, etc of my NextJS apps in the same mono repo. My workaround right now is force overriding bun-types in those apps but that doesn't seem ideal and costs me a lot of headaches to find.

Expected behavior

Not do that

Environment & setup

Turbo PNPM Monorepo.

rtorcato commented 1 year ago

I'm having this problem too. Can't use Drizzle in a mono repo. I'm using Turbo repo.

found this note on Bun docs

DOM types

Unfortunately, setting a value for "types" means that TypeScript will ignore other global type definitions, including lib: ["dom"]. If you need to add DOM types into your project, add the following triple-slash directives at the top of any TypeScript file in your project.

/// <reference lib="dom" />
/// <reference lib="dom.iterable" />

Update Fix: after adding the reference libs to a typescript file in my nextjs app it fixes the problem

tscritch commented 10 months ago

@rtorcato thank you 🙏🏻

Update Fix: after adding the reference libs to a typescript file in my nextjs app it fixes the problem

I'm using a turbo repo with drizzle and Vite. I added your suggestion to my vite-env.d.ts file and it works now.

This broke when I upgraded drizzle from 0.27.2 to 0.29.1.

For weary travelers hopefully google picks this up for you: error TS2304: Cannot find name 'window'