4. implement Record<K, V>
Share
- accepted / - tried
Record<K, V>
returns an object type with keys of K and values of V.
Please implement MyRecord<K, V>
by yourself.
Notice that property key could only be number | string | symbol
.
type Key = 'a' | 'b' | 'c'const a: Record<Key, string> = { a: 'BFE.dev', b: 'BFE.dev', c: 'BFE.dev'}a.a = 'bigfrontend.dev' // OKa.b = 123 // Errora.d = 'BFE.dev' // Errortype Foo = MyRecord<{a: string}, string> // Error