Feature: typescript used to typecheck API/AJAX responses #5392
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Out of Scope
This idea sits outside of the TypeScript language design constraints
Suggestion
An idea for TypeScript
Actually, it's not typescript itself, but a couple of more tools used along.
The idea is to typecheck runtime responses - whether they conform to typescript types. TS does typecheck in compille time and the AJAX responses come in runtime, therefore TS can't do that on its own. But if we use typson to dump TS types down to JSON Schemas and to use a JSON Schema validator along with it to do checking in runtime. The idea is also described in lbovet/typson#37.
I know typson is not a part of typescript. But it's doable to configure such tool stack for developers. And the benefits would be really great to typecheck a real API, especially, that developers (end-users of typescript) woudln't have to write anything more than they do now (as long as the AJAX calling function, whatever it is, calls the provided ts-json-schema-validation-mechanism function).
It could be also a built-in feature of TypeScript, though, it would create a dependency on typson, which might not be what you want. What do you think of such idea? Are you interested in using typescript to do runtime API typecheck?
The text was updated successfully, but these errors were encountered: