Skip to content

Partial type inference failures with tagged union types #13754

Closed
@falsandtru

Description

@falsandtru

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.

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