You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create an object of that type and give it extra properties, Typescript throws an error.
let fish: Fish = {
name: 'Bubbles',
numberOfLegs: 2
};
Type '{ name: string; numberOfLegs: number; }' is not assignable to type 'Fish'.
Object literal may only specify known properties, and 'numberOfLegs' does not exist in type 'Fish'.
However, if you create an object validator with extra properties, no type error occurs.
let fishValidator: ObjectValidator<Fish> = v.object({
name: v.string().required(),
numberOfLegs: v.number().required()
});
I would expect the same error to be reported if extra properties exist in the object validator definition but do not exist in the specified type. Am I misunderstanding something here? Thanks in advance!
The text was updated successfully, but these errors were encountered:
Say we have the following TS interface
If you create an object of that type and give it extra properties, Typescript throws an error.
However, if you create an object validator with extra properties, no type error occurs.
I would expect the same error to be reported if extra properties exist in the object validator definition but do not exist in the specified type. Am I misunderstanding something here? Thanks in advance!
The text was updated successfully, but these errors were encountered: