Skip to content

Partial type inference failures with tagged union types #13754

Description

Probably an example without the type guard of #13454.

TypeScript Version: master

Code

declare function f<P, R, S>(process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>): void;
namespace Supervisor {
  export type Process<P, R, S> = {
    readonly init: Process.Init<S>;
    readonly call: Process.Call<P, R, S>;
    readonly exit: Process.Exit<S>;
  };
  export namespace Process {
    export type Init<S> = (state: S) => S;
    export type Call<P, R, S> = (param: P, state: S) => [R, S] | PromiseLike<[R, S]>;
    export type Exit<S> = (state: S, reason: any) => void;
  }
}
f<void, void, void>({
  init: s => s,
  call: (p, s) => <[void, void]>[p, s],
  exit: s => void s,
});

Expected behavior:

ok

Actual behavior:

$ node built/local/tsc.js -t es6 index.ts --noImplicitAny
index.ts(16,10): error TS7006: Parameter 'p' implicitly has an 'any' type.
index.ts(16,13): error TS7006: Parameter 's' implicitly has an 'any' type.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions