Type Challenges Judge

Type Lookup

提出詳細

type Lookup<T extends { type: String }, U extends string> = T extends { type: U } ? T : never
提出日時2023-05-03 00:48:19
問題Type Lookup
ユーザーDowanna
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' interface Cat { type: 'cat' breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' } interface Dog { type: 'dog' breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' color: 'brown' | 'white' | 'black' } type Animal = Cat | Dog type cases = [ Expect<Equal<LookUp<Animal, 'dog'>, Dog>>, Expect<Equal<LookUp<Animal, 'cat'>, Cat>>, ]