3 ms·
>I miss being able to spread the properties of one type into another, rather than having to inherit from an interface) What would that achieve that intersectio
by ImprobableTruth 4y ago
>I miss being able to spread the properties of one type into another, rather than having to inherit from an interface)
What would that achieve that intersection types don't already?
- Kejistan 4y agoSpreads are ordered, and try to match the semantics of object spreads at runtime. Intersection types don't do that, they express that the type is both things at the same time. It is most obvious when dealing with types that have overlapping properties: [typescript with intersections](https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDeAoK6oDMD22BcUAdgK4C2ARhAE4DcaG5AhlQQM7BUCWhA5nQL50UAEwgBjADbNoY7IXZRW2UhBgEYQ0JCgAhBMnroc+RR259DUJgC82Z3gKGjJ0qLPnBFyiDoI7N4NAAwvpwAGS6TuJSVNCYxIRiwJxyUMAQ7AAUYgRBAJQEAG7YnMJCAPTlUABExtVQnKxE2ADuUAAGhBCF1O1pgcIo6VmoGFAAdJNKKjAANJaT49M+8-x5mhnAmaMYxgQADPNjTCxQAOTsVGdHDIy255fXKGt0QA https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDeA...) [flow with spreads](https://flow.org/try/#0C4TwDgpgBAglC8UDeAfAUFTUBmB7XAXFAHYCuAtgEYQBOA3BlpQIY1EDOwNAlsQOYMUAXwZoAJhADGAG1bQAbqyjtc5CDCIxRoSFABCCZOiw58HLrwGNMLAF7me-QSLTipsmgqUq1eonu1waABhQyQAOkiYABooSPC9FzcZORxSYklgblxiKGAITgAKSSJggEoieVxuMW0C4EKkazjIn3Vo5vi2vQ6hMtEAegGoAGUAC1xSaTFiAHJgKAB3XBoAayhqSWZSdmg8XChudjmF5mULfjR8oqaTfaIABg6TFjYoWc4aWeemZnt3z7fNB9OhAA https://flow.org/try/#0C4TwDgpgBAglC8UDeAfAUFTUBmB7XAXFAHYCu...).
- mirekrusin 4y agoThey map onto same type as runtime spread, ie. order matters last one overwrites.