Why doesn't TypeScript complain about interface violations resulting from Object.create?

前端 未结 0 1665
野的像风
野的像风 2021-01-12 05:02
type Foo = {
  x: number;
};

function g(): Foo {
  return {}; // Fails type-check

  // Property \'x\' is missing in type \'{}\' but required in type \'Foo\'.
}

fu         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题