Open
Description
π Search Terms
keyof index constraint filtering mapped
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
type Values<T> = T[keyof T];
type ProvidedActor = {
src: string;
logic: unknown;
};
interface StateMachineConfig<TActors extends ProvidedActor> {
invoke: {
src: TActors["src"];
};
}
declare function setup<TActors extends Record<string, unknown>>(_: {
actors: {
[K in keyof TActors]: TActors[K];
};
}): {
createMachine: (
config: StateMachineConfig<
Values<{
[K in keyof TActors as K & string]: {
src: K;
logic: TActors[K];
};
}>
>,
) => void;
};
π Actual behavior
Type 'Values<{ [K in keyof TActors as K & string]: { src: K; logic: TActors[K]; }; }>' does not satisfy the constraint 'ProvidedActor'.
Types of property 'src' are incompatible.
Type 'keyof { [K in keyof TActors as K & string]: { src: K; logic: TActors[K]; }; }' is not assignable to type 'string'.
Type 'string | number | symbol' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.(2344)
π Expected behavior
It should typecheck
Additional information about the issue
Almost the same thing typechecks OK if we refactor this to [K in keyof TActors & string]
.