-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hi there! Thanks for this wonderful library. Just wanted to report what appears to be an inaccuracy in the type annotation for encode():
Lines 61 to 63 in f531383
| export function encode(value: any): Buffer | |
| export function encodeAsIterable(value: any): Iterable<Buffer | Blob | AsyncIterable<Buffer>> | |
| export function encodeAsAsyncIterable(value: any): AsyncIterable<Buffer> |
It returns a Buffer, but when I call encode() in a browser, I get a Uint8Array instead:
This means that when you use it in TypeScript, I get an error when trying to type it as Uint8Array:
Type casting as workaround seems to resolve compile time issue:
// Note: The types for cbor-x are incorrect here, as encode() actually
// returns a Uint8Array in the browser. Cast to fix the type error.
const data = <Uint8Array>(encode(message) as unknown);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels