Why is an interface with an additional property handled differently than an interface? Are all properties that are considered optional for a type statement if none of them are explicitly defined?
interface WithOptionalProperty {
requiredProperty: string;
optionalProperty?: string;
}
let a = { optionalProperty: '' } as WithOptionalProperty;
interface WithoutOptionalProperties {
requiredProperty: string;
anotherRequiredProperty: string;
}
let b = { anotherRequiredProperty: '' } as WithoutOptionalProperties;
source
share