Type Challenges Judge

Trunc

提出詳細

type Trunc<T extends string | number> = `${T}` extends `${infer L}.${number}` ? L extends `${number}` ? L : "0" : `${T}`
提出日時2023-08-31 18:13:46
問題Trunc
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Trunc<0.1>, '0'>>, Expect<Equal<Trunc<1.234>, '1'>>, Expect<Equal<Trunc<12.345>, '12'>>, Expect<Equal<Trunc<-5.1>, '-5'>>, Expect<Equal<Trunc<'1.234'>, '1'>>, Expect<Equal<Trunc<'-10.234'>, '-10'>>, Expect<Equal<Trunc<10>, '10'>>, ]