Skip to content

Impossible to call reviver without immutable prop set #1115

@bruvvn

Description

@bruvvn

@redux-devtools/extensions

There is an issue when a reviver is set inside of devtools extensions serialize options and serialize option immutable is not set.

Reviver will never get called if immutable is not set.

It seems that the conditional is somehow mixed up due to typescript migration (#756).
Before the condition was checking for serialize.reviver now it checks for !!serialize.immutable. This is probably a mistake since function name is isSerializeWithReviver and also because the function isSerializeWithImmutable is returning exactly the same condition.

See js code before with serialize.reviver check:

} else if (serialize.reviver) {
parse = (v) => jsan.parse(v, serialize.reviver);
}

and ts code afterwards with !!serialize.immutable checking:

} else if (isSerializeWithReviver(serialize)) {
parse = (v) => jsan.parse(v, serialize.reviver);
}

function isSerializeWithReviver(
serialize: boolean | SerializeWithImmutable
): serialize is SerializeWithRequiredReviver {
return !!(serialize as SerializeWithImmutable).immutable;
}

Here you can see that the return of both functions isSerializeWithReviver is exactly the same isSerializeWithImmutable

function isSerializeWithImmutable(
serialize: boolean | SerializeWithImmutable
): serialize is SerializeWithRequiredImmutable {
return !!(serialize as SerializeWithImmutable).immutable;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions