当您使用 时Partial<SomeType>,从技术上讲,一个空对象满足该类型检查。有办法排除吗?
interface MyType {
foo: string
bar: string
}
function someFunction(obj: Partial<MyType>) {
// whatever
}
someFunction({}) // ideally, I would like this should throw a type error
Run Code Online (Sandbox Code Playgroud) typescript ×1