|
|
|
|
|
by mcv
2310 days ago
|
|
The second one is what I did: I've got a function that I can throw any of my anonymous data objects into, and it turns it into a typed object that knows its type and has the relevant class methods. And this worked fine with Typescript as long as nobody accidentally introduced a wrong class. Or actually it kept working fine after that, because the system simply ignored the types during runtime, so nobody noticed there was one bad class in the mix. Anyway, we're going back to simple JSON objects. Typescript is clearly not helping in our case, and the whole process with parsing all incoming objects is fairly cumbersome without adding much value. |
|
“io-ts introduces the concept of a runtime type (an instance of the Type class) which represents a runtime validator for a typescript (static) type. [2]”
See:
[1] https://gcanti.github.io/io-ts/
[2] https://lorefnon.tech/u2018/03/25/typescript-and-validations...