printf
提出詳細
type Func = (...args: any) => any type Format<T extends string, Res extends Func | string = string> = T extends `${infer L}%${infer F}${infer R}` ? F extends 's' ? Res extends Func ? Format<R, ((...args: Parameters<Res>) => (s1: string) => ReturnType<Res>)> : Format<R, (s1: string) => string> : F extends 'd' ? Res extends Func ? Format<R, ((...args: Parameters<Res>) => (d1: number) => ReturnType<Res>)> : Format<R, (d1: number) => string> : Format<R, Res> : Res
提出日時 | 2023-08-21 07:57:13 |
---|---|
問題 | printf |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Format<'abc'>, string>>, Expect<Equal<Format<'a%sbc'>, (s1: string) => string>>, Expect<Equal<Format<'a%dbc'>, (d1: number) => string>>, Expect<Equal<Format<'a%dbc%s'>, (d1: number) => (s1: string) => string>>, ]