Siilwyn
Siilwyn2mo ago

DNT build type check fails on std/streams/buffer byobRequest

So using dnt to build a short script which uses node's child_process and web streams I'm getting type errors on Deno's std/streams/buffer code. Specifically:
std@0.220.1/streams/buffer.ts:32:59 - error TS2339: Property 'view' does not exist on type 'never'.
const view = new Uint8Array(controller.byobRequest!.view!.buffer);
~~~~
std@0.220.1/streams/buffer.ts:32:59 - error TS2339: Property 'view' does not exist on type 'never'.
const view = new Uint8Array(controller.byobRequest!.view!.buffer);
~~~~
Any ideas on workaround (apart from disabling the build type check) or a fix?
3 Replies
Deno AI Helper
Deno AI Helper2mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message you've provided, it seems like there might be a type mismatch or an incorrect assumption about the type of controller.byobRequest. The error suggests that TypeScript expects controller.byobRequest to be of type never, which means that no further properties should be accessed on it, yet the code attempts to access a view property. Without the full context of the code, it's difficult to provide a precise solution, but here are a couple of things you might want to check: 1. Ensure that controller.byobRequest is indeed an instance of BYOBRequest and that it is not null or undefined at the time of accessing its view property. The non-null assertion operator ! is used, which assumes that byobRequest is not null or undefined. If there's a chance that it could be, you should handle that case. 2. Verify that the version of the std library you are using is compatible with the version of Deno you are working with. Sometimes, type errors can arise from version mismatches where the types defined in the library do not align with the runtime environment. 3. If you are confident that controller.byobRequest should have a view property and that this is a valid operation, you might be facing an issue with the type definitions. In such a case, you could try to locally modify the type definitions as a workaround, but this is not a recommended long-term solution. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If the issue persists, you might want to consider reaching out to the Deno community or the maintainers of the std library for more
Leokuma
Leokuma2mo ago
Can you provide a reproducible code snippet?