No, it is not possible to prevent any
from being returned in a JSON.parse reviver, as the reviver function does not have full control over the parsed JSON. The any
type is used in TypeScript to represent any type and can be returned if the JSON data contains values that cannot be parsed into a specific type. However, you can type-check the result of the JSON.parse function and handle the any
values properly.
Asked: 2021-12-24 11:00:00 +0000
Seen: 15 times
Last updated: Jun 01 '21