microsoft / microsoft/TypeScript

redux-orm broken by #43624

Offen
#43,867 4 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@weswigham arbeitet bereits daran.

Seit 28.4.2021.

Bug Domain: This-Typing Rescheduled
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

The nightly dtslint run for 4/28 fails on redux-orm, with new errors on examples like:

export default class Model<MClass extends typeof AnyModel = typeof AnyModel, Fields extends ModelFieldMap = any> {
    // ...
    readonly ref: Ref<this>;
    // ...
}
export class AnyModel extends Model {}
export type Ref<M extends AnyModel> = {
    [K in keyof RefFields<M>]: ModelFields<M>[K] extends AnyModel ? IdType<ModelFields<M>[K]> : RefFields<M>[K];
};
ERROR: 118:23  expect  TypeScript@4.3 compile error: 
Type 'this' does not satisfy the constraint 'AnyModel'.
  Type 'Model<MClass, Fields>' is not assignable to type 'Model<typeof AnyModel, any>'.
    Type 'typeof AnyModel' is not assignable to type 'MClass'.
      'typeof AnyModel' is assignable to the constraint of type 'MClass', but 'MClass' could be instantiated with a different subtype of constraint 'typeof AnyModel'.

Almost certainly a result of https://github.com/microsoft/TypeScript/pull/43624, but it could be #42449 or #43835, since they went in on the same day.

If this is an intended result of that PR, can you fix up redux-orm? A naive change to Ref<M extends Model> doesn't work.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.