-
Notifications
You must be signed in to change notification settings - Fork 171
[proposal] fix: type check issues on encod/decode arguments #139
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,11 @@ const defaultEncodeOptions: EncodeOptions = {}; | |
* | ||
* The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`. | ||
*/ | ||
export function encode<ContextType>( | ||
export function encode<ContextType = undefined>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless giving
Even though this error can be avoidable by giving explicit type annotation to the code above like |
||
value: unknown, | ||
options: EncodeOptions<SplitUndefined<ContextType>> = defaultEncodeOptions as any, | ||
): Uint8Array { | ||
const encoder = new Encoder<ContextType>( | ||
const encoder = new Encoder( | ||
options.extensionCodec, | ||
(options as typeof options & { context: any }).context, | ||
options.maxDepth, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto https://github.com/msgpack/msgpack-javascript/pull/139/files#diff-1c15ba03a28a5b41ad552a44b1fdb89fR46