Here's an example of a Yup schema I created to fetch entities known as Parcels:
export const FindParcelsParamsSchema = Yup.object({
cursor: Yup.number().optional(),
pageSize: Yup.number().positive().integer().optional(),
});
All fields are optional.
Next, let's look at the interface I'm trying to generate for this schema:
export interface IParcelsFetchingParams extends Yup.InferType<typeof FindParcelsParamsSchema> { }
I believe I should be able to declare this variable like so:
let params: TParcelsFetchingParams = {};
But TypeScript keeps raising this error message:
Type '{ cursor: undefined; pageSize: undefined; }' is missing the following properties from type...
Unless I add all the fields as undefined:
let x: TParcelsFetchingParams = {
cursor: undefined,
pageSize: undefined,
};
My tsconfigs are set as follows:
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true
}
So why exactly am I encountering this issue, and what steps can I take to resolve it?
I expect to be able to declare my variable with either no properties or just one without any problems.