Error - The type you provided for 'Storage' is not a valid LSON value

Why this error occurred

You have provided a custom Storage type for your application, but the type you provided isn’t a (completely) valid LSON object. Values like Date, Map, Set, functions, classes, or unknown aren’t valid LSON.

What was LSON again?

LSON is either a valid JSON value, or an instance of LiveMap, LiveList, LiveObject, or LiveFile.

In the example above, the problem is in the Date field, because a Date isn’t a valid LSON value.

How to fix it

You’ll need to figure out what part of your provided Storage type definition isn’t valid LSON. Sometimes this is immediately obvious, like in the example above.

Sometimes the issue may be a bit less obvious:

By using Lson, you can still work with unknown or unspecified values, but still ensure they will be valid LSON.

If you cannot find the root cause

Sometimes types can be complex and the root cause is still unclear. In those cases, there is a small trick you can use. Try to assign your type to the required base type, with this line:

Now TypeScript will explain why it thinks your type isn’t valid LSON: