Skip to content

Comparison targets are reversed (regression) #31251

Open
@falsandtru

Description

@falsandtru

The similar problem #30118 had been fixed, but appeared again.

TypeScript Version: 3.4.0-dev.20190504

Search Terms:

Code

export abstract class Supervisor<N extends string, P = unknown, R = unknown> {
  private static instances_: Set<Supervisor<string, unknown, unknown>>;
  private static get instances(): typeof Supervisor.instances_ {
    return this.hasOwnProperty('instances_')
      ? this.instances_
      : this.instances_ = new Set();
  }
  constructor() {
    void (this.constructor as typeof Supervisor).instances.add(this);
  }
  public abstract call(name: N | ('' extends N ? undefined : never), param: P, timeout?: number): Promise<R>;
}

Expected behavior:

pass

Actual behavior:

Argument of type 'this' is not assignable to parameter of type 'Supervisor<string, unknown, unknown, unknown>'.
  Type 'Supervisor<N, P, R, S>' is not assignable to type 'Supervisor<string, unknown, unknown, unknown>'.
    Type 'string' is not assignable to type 'N'.
      'string' is assignable to the constraint of type 'N', but 'N' could be instantiated with a different subtype of constraint 'string'.ts(2345)

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions