TypeScript 类型推断回归(回归)

rjzwgtxy  于 6个月前  发布在  TypeScript
关注(0)|答案(2)|浏览(48)

TypeScript版本:3.0.0-dev.20200312
搜索词:
代码:

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>;
}

预期行为:通过
实际行为:类型'never'上不存在属性'id'。(2339)
Playground链接: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
相关问题:

5t7ly7z5

5t7ly7z51#

简化后的文本内容为:

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;
}
tv6aics1

tv6aics12#

看起来是在 #32774 之后出现的。

相关问题