Open irbull opened 1 week ago
This checks out fine if I change the signature to:
function returnBuffer(): NodeJS.ArrayBufferView {
return new Uint8Array([1, 2, 3, 4, 5]);
}
Breaking changes may have occurred in @types/node for TypeScript 5.7 Beta support.
https://devblogs.microsoft.com/typescript/announcing-typescript-5-7-beta/#typedarrays-are-now-generic-over-arraybufferlike
@irbull NodeJS.ArrayBufferView
type seems to be stricter than the ArrayBufferView
type.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a8bde6b92a06d9da2735a04ab611058bfa21c20b/types/node/globals.d.ts#L486-L498
So, this is a TypeScript issue rather than a Deno issue.
But it's unclear to me what type (ArrayBufferView or NodeJS.ArrayBufferView) should be used when using the node.js shims. This same code works fine in Node (it's actually part of my Astro Build website), but the code doesn't build properly with Deno. It seems writeFileSync
wants a NodeJSArrayBufferView
.
Version: Deno 2.0
While trying to build an Astro site with Deno 2.0 I hit an error about mismatched types. I have managed to create a reproducible snippet that should help track this down:
This seems to be valid typescript, but
deno check
fails with:This could be a duplicate of https://github.com/denoland/deno/issues/22381