4 ms·
> How practical such a type system would be... I don't know. Flow type checker for JavaScript makes a distinction between "exact" types, i.e. object must have e
by seanwilson 5y ago
> How practical such a type system would be... I don't know. Flow type checker for JavaScript makes a distinction between "exact" types, i.e. object must have exactly the properties listed and no more, and "inexact" types where such subtyping is allowed.
TypeScript doesn't have this check (https://github.com/Microsoft/TypeScript/issues/12936 https://github.com/Microsoft/TypeScript/issues/12936) and I've found it can be really error prone when you're wanting to return a copy of an object with some fields updated. Spot the bug in this example: https://www.typescriptlang.org/play?#code/C4TwDgpgBAKlC8UDeUCWATAXFAzsATqgHYDmANFAMYD2ANrRJcKtUdnoaQNoC6AvgG4AsAChRAMwCuRJiyJQAhunQAKYJhgUAbgtqSI7AsRIBKKBuSio1qqzxRJYdAuDRESGvUbNWAJmxcAHTBwIGeDLKs2rr6-MIiNlD4EMCS+PJIwYHAFFmOzq6ConyiojREOHQQgbTUJCpKqkgYmABEAB6tFOHecphcrQpdUK0ARq38FK2UrSYm8UA https://www.typescriptlang.org/play?#code/C4TwDgpgBAKlC8UDeU...