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

ReadableStream.from method fails type-checking in v1.45.0+ if you import openai package #24578

Closed
Macil opened this issue Jul 14, 2024 · 1 comment · Fixed by #24599
Closed

Comments

@Macil
Copy link

Macil commented Jul 14, 2024

import "npm:openai@^4.52.7";

const rs = ReadableStream.from([
  new Uint8Array([5, 6, 7]),
]);
> deno check .\main.ts
Check file:///E:/chris/Coding/deno-test/main.ts
error: TS2339 [ERROR]: Property 'from' does not exist on type '{ new (underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number | undefined; } | undefined): ReadableStream<Uint8Array>; new <R = any>(underlyingSource: UnderlyingDefaultSource<...>, strategy?: QueuingStrategy<...> | undefined): ReadableStream<...>; new <R = any>(underlyingSource?: UnderlyingSourc...'.
const rs = ReadableStream.from([
                          ~~~~
    at file:///E:/chris/Coding/deno-test/main.ts:3:27

This error does not happen if you remove the import.

This error does not happen in Deno 1.44.4. This error happens in 1.45.0 and above.

In VSCode, if I ctrl-click on ReadableStream in the code, I see that both lib.deno.web.d.ts and lib.dom.d.ts declare an interface and variable named ReadableStream, and polyfill.d.ts (from the "web-streams-polyfill" npm package, a dependency of the "openai" package) declares an interface named ReadableStream. If I comment out the import, then only the lib.deno.web.d.ts entry appears without the other two.

image

The variable declared by lib.dom.d.ts is missing the from method which is present in the variable declared by lib.deno.web.d.ts and there are some other inconsistencies in the new overloads. I think this problem would be fixed either by these two declarations being made consistent, or by the declaration in lib.dom.d.ts being removed entirely (as it's redundant, assuming it's the case that lib.deno.web.d.ts is always loaded).

@petamoriken
Copy link
Contributor

We can patch lib.dom.d.ts such as #23893. I'll fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants