Closed
Description
TypeScript Version: 2.3.4
Code
interface Foo {
key: string
value: string
}
const shouldFail0: Partial<Foo> = '' // does not fail
const shouldPass0: Partial<Foo> = {} // does not fail
const shouldFail1: Partial<Foo> = {
ker: ''
} // fails
interface Bar {
(): Partial<Foo>
}
const shouldFail2: Bar = () => ({
car: ''
}) // does not fails
const shouldFail3: Bar = () => ('') // does not fails
const shouldFail4: Bar = () => {
return undefined
} // fails
I've setup a typescript playground example.
Expected behavior:
Partial type should not pass for values that are strings or incorrect objects.
Actual behavior:
Partial type passes for values that are strings and incorrect objects.