Type Challenges Judge

Trunc

提出詳細

type TruncImpl<T extends string> = T extends `${infer T1}.${infer T2}` ? T1 extends "" ? "0" : T1 : T type Trunc<T extends string | number> = TruncImpl<`${T}`>
提出日時2023-09-18 07:40:34
問題Trunc
ユーザーsankantsu
ステータス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'>>, ]