After the update to version 3.0.0, it is no longer possible to have optional properties on a JsonObject:
import { JsonObject } from "type-fest";
interface MyObject extends JsonObject {
optionalProp?: string
}
Gives a TypeError:
(property) MyObject.optionalProp?: string | undefined
Property 'optionalProp' of type 'string | undefined' is not assignable to 'string' index type '((string | number | boolean | JsonObject | JsonArray) & (string | number | boolean | JsonObject | JsonArray | undefined)) | null'.ts(2411)
How should this type be used correctly? The code above worked fine with version 2.x.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too