TypeScriptの関数型
#WIP
built in
Parameters<Fn>
ReturnType<Fn>
generic関数宣言内のVariadic Tuple Types
TypeScriptの2つの型引数を取るGeneric関数で、1つのみを必ず指定させる
TypeScriptの変性
制約
Function
https://github.com/type-challenges/type-challenges/blob/master/questions/191-medium-append-argument/README.ja.md
code:解1.ts
type AppendArgument<Fn extends Function, T> = (
...args:
...Parameters<Fn>, T
) => ReturnType<Fn>;
code:解2.ts
type AppendArgument<Fn extends Function, A> = Fn extends (
...args: infer Args
) => infer R
? (...args:
...Args, A
) => R
: Fn;
具体例
https://susisu.hatenablog.com/entry/2019/04/18/000858