facebook / facebook/flow

Intersection Types with Object Spread Behave Inconsistently

Offen
#4,782 3 Kommentare 11 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug Typing: spread Typing: unions/intersections
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When creating an intersection of two types, and spreading the "rest props" of that object value, flow does not track the properties with in the spread object properly.

However, if I merge the two types that I was creating an intersection with, the behavior is correct. [The documentation](https://flow.org/en/docs/types/intersections/#toc-intersections-of-object-types) implies that an intersection type should provide the intended typing, so this may be a bug with `flow@0.54`?

[This try flow](https://flow.org/try/#0JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wChSYBPMJOANRQBsBXJAZzgF44BvUuOADcmrNgC44AQShQUlADwA7ZiABGSKAD4ANKQC+5KjTgAhdBEVde-OIpQgkE-KvOL8ug6QD0XuDAAWwBxs-hDMjAAmthDwGjhQ2nCqzPDA8BEQ7ACEpJjMihjAFnAA5kgwDCzsABQ8tvZIiQB0LWA4YBx6EmZoxQBk9CLsAJTWAJC9imwQjEhNjBAl1W0QHU3CVWzD+uQ+foEcGezRsTLQOXkFMEWWMf4aAOLllaK19Q7Nre2dEnUtTT0LJ8mi9jnpRnw4BMLNNZvNFstvushls4DtyBigA) demonstrates the issue.

EDIT: I should also note, this does not error on 0.53 or 0.53.1 and could be related to the `Made rest parameters in object destructuring patterns sealed, and exact if possible` update in 0.54?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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