Type 'MyType' does not satisfy the constraint 'ObjectShape'. Index signature for type 'string' is missing in type 'MyType'

Viewed 1149

So, I recently upgraded

  • "yup": "^0.29.1" => "yup": "^0.32.11"
  • "@types/yup": "^0.29.3" => "@types/yup": "^0.29.13",

And now all of my Schemas are broken. I'll provide one example, which typescript is crying about:

export interface MyType {
  id: number;
  name: string;
  description: string | null;
}

export const mySchema = yup
  .object<MyType>({
    id: yup.number().required(),
    name: yup.string().trim().required().max(50),
    description: yup.string().trim().max(200).defined(),
  })
  .required();

Error from typescript:

TS2344: Type 'MyType' does not satisfy the constraint 'ObjectShape'. Index signature for type 'string' is missing in type 'MyType'.

What am I missing here?

0 Answers
Related