Type Challenges Judge

AnyOf

提出詳細

type FalsyValue = 0 | '' | false | [] type IsEmptyObject<T> = (keyof T) extends never ? true : false; type IsFalsyValue<T> = T extends FalsyValue ? true : IsEmptyObject<T> extends true ? true : false; type TrueExists<T extends readonly any[]> = T[number] extends false ? false : true; type ToBoolean<T extends readonly any[]> = { [I in keyof T]: IsFalsyValue<T[I]> extends true ? false : true } type AnyOf<T extends readonly any[]> = TrueExists<ToBoolean<T>>
提出日時2023-08-12 01:58:45
問題AnyOf
ユーザーtekihei2317
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<AnyOf<[1, 'test', true, [1], { name: 'test' }, { 1: 'test' }]>, true>>, Expect<Equal<AnyOf<[1, '', false, [], {}]>, true>>, Expect<Equal<AnyOf<[0, 'test', false, [], {}]>, true>>, Expect<Equal<AnyOf<[0, '', true, [], {}]>, true>>, Expect<Equal<AnyOf<[0, '', false, [1], {}]>, true>>, Expect<Equal<AnyOf<[0, '', false, [], { name: 'test' }]>, true>>, Expect<Equal<AnyOf<[0, '', false, [], { 1: 'test' }]>, true>>, Expect<Equal<AnyOf<[0, '', false, [], { name: 'test' }, { 1: 'test' }]>, true>>, Expect<Equal<AnyOf<[0, '', false, [], {}]>, false>>, Expect<Equal<AnyOf<[]>, false>>, ]