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

fix: allow other json values #2015

Merged
merged 1 commit into from Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions source/core/options.ts
Expand Up @@ -1349,13 +1349,11 @@ export default class Options {

__Note #2__: This option is not enumerable and will not be merged with the instance defaults.
*/
get json(): Record<string, any> | undefined {
get json(): any {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szmarczak I think it should return unknown.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it was Record<string, any> and not Record<string, unknown> 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing value was incorrect too, yes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, they should behave the same, I prefer using unknown whenever possible for consistency. I only use any when there's absolutely no other way.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return this._internals.json;
}

set json(value: Record<string, any> | undefined) {
assert.any([is.object, is.undefined], value);

set json(value: any) {
if (value !== undefined) {
assert.undefined(this._internals.body);
assert.undefined(this._internals.form);
Expand Down