Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A package using peer dependencies throws errors only when using astro check #976

Open
1 task
ytkimirti opened this issue Nov 1, 2024 · 0 comments
Open
1 task
Labels
needs triage Issue needs to be triaged

Comments

@ytkimirti
Copy link

Astro Info

Astro                    v4.16.8
Node                     v18.20.3
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

To use @upstash/redis package, you create a client object

const redis = new Redis({ ... })

We require this redis client object in the @upstash/ratelimit package

const ratelimit = new Ratelimit({
    redis: redis
})

However, this gives the following error, and specifically only when using astro check.

src/code.ts:11:3 - error ts(2719): Type 'import("/home/projects/vitejs-vite-lsvyuz/node_modules/@upstash/redis/nodejs").Redis' is not assignable to type 'import("/home/projects/vitejs-vite-lsvyuz/node_modules/@upstash/redis/nodejs").Redis'. Two different types with this name exist, but they are unrelated.
  Property 'client' is protected but type 'Redis' is not a class derived from 'Redis'.

11   redis: ratelimitRedis,
     ~~~~~

Result (3 files): 
- 1 error
- 0 warnings
- 0 hints

In the reproduction repo, you can try tsc which only includes the src/code.ts file. And it does not give a type error.

We have other integrations and we have only seen this error when using astro check. We can fix the issue with hacky methods but I think there might be a problem in the linter itself.

The ratelimit config object is basically this

import { Redis } from "@upstash/redis";

type RegionRatelimitConfig = {
  redis: Redis;
};

And @upstash/redis is a peer dependency in @upstash/ratelimit.

We discovered it thanks to this issue in our repo.

What's the expected result?

To not give any errors, like the tsc

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-lsvyuz?file=src%2Fcode.ts

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 1, 2024
@florian-lefebvre florian-lefebvre transferred this issue from withastro/astro Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant