Skip to content

String completions fail when they depend on the contextual signatureΒ #53073

Closed
@Andarist

Description

@Andarist

Bug Report

πŸ”Ž Search Terms

completions string return contextual signature

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type ActorRef<TEvent extends { type: string }> = {
  send: (ev: TEvent) => void;
};

type Action<TContext> = {
  (ctx: TContext): void;
};

type Config<TContext> = {
  entry: Action<TContext>;
};

declare function createMachine<TContext>(config: Config<TContext>): void;

type EventFrom<T> = T extends ActorRef<infer TEvent>
  ? TEvent
  : never;

declare function sendTo<TContext, TActor extends ActorRef<any>>(
  actor: (ctx: TContext) => TActor,
  event: EventFrom<TActor>
): Action<TContext>;

createMachine<{
  child: ActorRef<{ type: "EVENT" }>;
}>({
  entry: sendTo((ctx) => ctx.child, { type: /*1*/ }),
});
createMachine<{
  child: ActorRef<{ type: "EVENT" }>;
}>({
  entry: sendTo((ctx) => ctx.child, { type: "/*2*/" }),
});

πŸ™ Actual behavior

At marker 2 TypeScript fails to provide a string completion

πŸ™‚ Expected behavior

I expect the string completion at marker 2 to behave in the same way as the regular completion at marker 1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions