tsargs icon indicating copy to clipboard operation
tsargs copied to clipboard

Is there a way to pick the first argument of a function, but keeping the generic?

Open christopher-francisco opened this issue 4 years ago • 0 comments

https://codesandbox.io/s/currying-thunder-ulqj6?file=/src/index.ts

Basically I'd like to keep the generic def but I don't seem to figure out how to

import { ESLintUtils } from "@typescript-eslint/experimental-utils";
import { Arg1 } from "tsargs";

type RuleCreator = ReturnType<typeof ESLintUtils.RuleCreator>;

// FirstArg defines "meta" as CreateRuleMeta<string> instead of CreateRuleMeta<TMessageIds>
type FirstArg = Arg1<RuleCreator>;

// FirstParam defines "meta" as CreateRuleMeta<string> instead of CreateRuleMeta<TMessageIds>
type FirstParam = Parameters<RuleCreator>[0];

christopher-francisco avatar Sep 28 '21 20:09 christopher-francisco