Comment by mirekrusin
3 years ago
Those are exact object types which have first class support in flow and no support with exception of literals like you mention in typescript. Flow is ahead in this case.
3 years ago
Those are exact object types which have first class support in flow and no support with exception of literals like you mention in typescript. Flow is ahead in this case.
I believe this implements an exact object type in Typescript:
Credit goes to Manan Tank: https://twitter.com/MananTank_/status/1677610004743086080
No, it doesn't.
It can't be represented in TypeScript type system.
You can't create utility type to have it.
Have a look at Flow docs [0] if you want to learn more.
His utility type works on diff between two provided types, this is something else.
Exact object type is a kind of type which doesn't allow extra, undeclared properties to be used for it to be satisfied.
You can't emulate it if it's not supported by type system.
The whole thing is implemented way better in Flow than TypeScript, ie. spreads map to how runtime treats them, this is also not something TypeScript can represent and Flow supports.
Also opaque types have first class support and many other things.
[0] https://flow.org/en/docs/types/objects/#exact-and-inexact-ob...