microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.13k stars 12.5k forks source link

Type inference regression (regression) #37383

Open falsandtru opened 4 years ago

falsandtru commented 4 years ago

TypeScript Version: 3.0.0-dev.20200312

Search Terms:

Code

export interface Supervisor<N extends string, P = undefined, R = P, S = undefined> {
  constructor: typeof Supervisor;
}
export abstract class Supervisor<N extends string, P = undefined, R = P, S = undefined> {
  constructor() {
    if (this.constructor === Supervisor) this.id;
  }
  public id = 0;
  public abstract call(name: N | ('' extends N ? undefined | ((names: Iterable<N>) => Iterable<N>) : never), param: P, timeout?: number): Promise<R>;
}

Expected behavior: pass Actual behavior: Property 'id' does not exist on type 'never'.(2339) Playground Link: http://www.typescriptlang.org/play/index.html?ts=3.9.0-dev.20200312&ssl=1&ssc=1&pln=10&pc=2#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgZQFcw0A3BAZ2gB4A5OUVJAEwrgpimQHMAaOAApwAvHEItg6ZMGb8ASiMH98i8c0nTmAPjgBvAFBw42CEg5RC2GNABccGAE8SEdAWJlK0ANz6AvvtBIWDhMACNzHHhsABtMCjYiEihyKig6BhAmVnZOHn4hUTUNJBl5RQFlVQkpEu09Q2NTc0trKAAKAEp6oyMEVzaYAAtKADoTM04W6BFhUUSPVK6h0YRmHyN-IzBCUOiEbERmRQAGdbht3f2Q8M5I40xo6LakTABbYDt6AB84NoByP4ZLJsegAfjE1U0cB+bWeb2AFDsAElUFAwtFgHQtF1hDoUWh0ZjaNi4HYSqQ0B1+GBMGjXnYKvYEO8IIQYKCyYRXqFKQyoBBXpRMXItD5fEA

Related Issues:

RyanCavanaugh commented 4 years ago

Simplified a bit:

interface SomeClass<N> {
  constructor: typeof SomeClass;
}
abstract class SomeClass<N> {
  constructor() {
    if (this.constructor === SomeClass) this.id;
  }
  public id = 0;
  public abstract foo(name: ('' extends N ? undefined: null)): any;
}
hikarino-my commented 4 years ago

Seems to be appearing after https://github.com/microsoft/TypeScript/pull/32774