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

ReadableStreamDefaultControllerCallback/UnderlyingSourcePullCallback<string>.enqueue "not callable" type checking error in 1.45.3 #24738

Closed
valpackett opened this issue Jul 26, 2024 · 0 comments · Fixed by #24770

Comments

@valpackett
Copy link

Version: Deno 1.45.3

#24599 has introduced a very strange typechecking error to my usage of the ReadableStream API:

full code for reference

Check file:///home/val/src/codeberg.org/valpackett/tiddlypwa/server/app.ts
error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'ArrayBufferView & string'.
  Type 'string' is not assignable to type 'ArrayBufferView'.
                        ctrl.enqueue(`{"appEtag":${JSON.stringify(appEtag)},"serverChanges":[`);
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///home/val/src/codeberg.org/valpackett/tiddlypwa/server/app.ts:122:17

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'ArrayBufferView & string'.
                                                (firstWritten ? '\n,' : '\n') + JSON.stringify({
                                                ^
    at file:///home/val/src/codeberg.org/valpackett/tiddlypwa/server/app.ts:131:7

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'ArrayBufferView & string'.
  Type 'string' is not assignable to type 'ArrayBufferView'.
                        ctrl.enqueue('\n]}');
                                     ~~~~~~
    at file:///home/val/src/codeberg.org/valpackett/tiddlypwa/server/app.ts:156:17

Found 3 errors.

Interestingly the LSP server reports it completely differently, in a way that makes more sense than just somehow deriving an intersection type:

editor screenshot

This expression is not callable. Each member of the union type '{ (chunk: ArrayBufferView): void; (chunk: ArrayBufferView): void; } | { (chunk?: string | undefined): void; (chunk?: string | undefined): void; }' has signatures, but none of those signatures are compatible with each other.

soooo… that doesn't look good 🤔

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.

1 participant