You can use the TypeScript utility type Parameters instead of inferring the type of your F function 1st argument (props).
Constructs a tuple type from the types used in the parameters of a function type Type.
From there, you can directly be more specific to constrain your K generic, instead of just extends string: for example K extends keyof Parameters<F>[0]
Now to be even closer to your example, we could make it so F can be something else than a function, in which case the conditions are slightly more complicated, but still do-able:
type OmitFields<
F,
K extends (
F extends (...args: any) => any
? keyof Parameters<F>[0]
: string
)
> = F extends (...args: any) => infer R
? (props: Omit<Parameters<F>[0], K>) => R
: never;
declare function functionWithObjectParam(props: { key1: number; second: boolean; }): string;
type Omitted = OmitFields<typeof functionWithObjectParam, 'first' | 'second'>
// TS2344 Type '"first" | "second"' does not satisfy the constraint '"second" | "key1"'. Type '"first"' is not assignable to type '"second" | "key1"'.
type Omitted2 = OmitFields<typeof functionWithObjectParam, 'key1' | 'second'> // Okay
type Omitted3 = OmitFields<string, 'first' | 'second'> // Okay
However I suspect that in your case the conditional type was only to enable type inference. In the case you can have a type that accepts only functions, it becomes much simpler:
type OmitFields2<
F extends (...args: any) => any,
K extends keyof Parameters<F>[0]
> = (props: Omit<Parameters<F>[0], K>) => ReturnType<F>
type Omitted4 = OmitFields2<typeof functionWithObjectParam, 'first' | 'second'>
// TS2344 Type '"first" | "second"' does not satisfy the constraint '"second" | "key1"'.
type Omitted5 = OmitFields2<typeof functionWithObjectParam, 'key1' | 'second'> // Okay
type Omitted6 = OmitFields2<string, 'first' | 'second'>
// TS2344 Type 'string' does not satisfy the constraint '(...args: any) => any'.
Demo