有人可以解释为什么这不会引发错误吗?
interface A {
id?: number;
}
const a:A = {
id: 5
};
const testA: boolean = (a === 1); //works, but why?
interface B {
id: number;
}
const b:B = {
id: 5
};
const testB: boolean = (b === 1); //compiler error -> expected that also on A
Run Code Online (Sandbox Code Playgroud)
typescript ×1