why interface couldn't extend Record
interface Data {
a: string
}
Data extends Record<string, unknown> ? 'yes' : 'no' // 'no'
however, if I change the Data to type it works fine
type Data {
a: string
}
Data extends Record<string, unknown> ? 'yes' : 'no' // 'yes'
type T = Record<string, unknown>
evaluates to { [x: string]: unknown; }
Object types have an implicit index signature, but interfaces don't (for safety reasons), so they don't extend an index type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With