You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought of a possible use case of typson and thought it might be great, if it worked out, though, I wanna discuss it with you all.
Let's assume we've got an application written in TypeScript. What TypeScript itself gives us is compile-time typecheck. That is great to find bugs statically, but it can't help us to check anything on runtime. Therefore, what we can do in TS code is to typecast the dynamic response (which we will determine in future) to a static type, but, when transpiled into raw javascript, it will not have any impact nor it will add any behavior.
Now let's say we want to validate contents of a GET request. We know that the expected result should match a given TypeScript type. We use typson to generate JSON schema for that type. And one of the JSON Schema validators (there are many of them in JS only) will be used to typecheck in runtime.
As far as I understand the whole stack of tools (and as long as typson supports typescript well), this would work correctly out of the box. Guess this feature should be somehow optional, so that we can validate all API responses in the development/test environments, but not in the production (due to performance reason).
Please comment on this - what do you think of that feature?
The text was updated successfully, but these errors were encountered:
Hello all,
I thought of a possible use case of typson and thought it might be great, if it worked out, though, I wanna discuss it with you all.
Let's assume we've got an application written in TypeScript. What TypeScript itself gives us is compile-time typecheck. That is great to find bugs statically, but it can't help us to check anything on runtime. Therefore, what we can do in TS code is to typecast the dynamic response (which we will determine in future) to a static type, but, when transpiled into raw javascript, it will not have any impact nor it will add any behavior.
Now let's say we want to validate contents of a GET request. We know that the expected result should match a given TypeScript type. We use typson to generate JSON schema for that type. And one of the JSON Schema validators (there are many of them in JS only) will be used to typecheck in runtime.
As far as I understand the whole stack of tools (and as long as typson supports typescript well), this would work correctly out of the box. Guess this feature should be somehow optional, so that we can validate all API responses in the development/test environments, but not in the production (due to performance reason).
Please comment on this - what do you think of that feature?
The text was updated successfully, but these errors were encountered: