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
{{ message }}
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
The issue we currently have is that Typescript definitions are basically worthless as soon as external data comes into play (such as JSON file sources), and we can still encounter runtime type errors. We could use some generators such as typescript-json-schema or ts-json-schema-generator but I don't know how reliable those are and if they really fit our needs.
At the same time, it almost seems like we're either:
being overkill with type-checking: the NunjucksJS templating engine will safely escape null, undefined and malicious values, so why have data classes at all? But they provide a common interface for all, at the cost of boilerplate...
do not have the right tools for end-to-end type verification: the source JSON files and the end template files are not aware of types anyway (so it's still easy to forget / misspell properties)
Ideally, we should change the toolchain such that we can support from data source to data output (for instance, using React as (server-side?) template engine would allow us to discover types in context). We could use any of the above libraries to ensure that JSON sources are valid. Or we could ditch type-checking altogether and greatly simplify the code, at the expense of letting the runtime safely escape errors (which would either be caught by Node anyway, or that would simply omit data in templates if they're incomplete).
At the very least, moving to ajv would probably make things a lot cleaner already
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Right now we're checking JSON contents manually: it's tedious and error-prone.
For instance the sponsors are checked as follows:
https://github.com/clicepfl/clic-website/blob/b2de1373d9f45e8b510db138b247d475475120a1/src/components/sponsors/sponsors.ts#L64-L91
We could use a library such as
ajv
(https://github.com/ajv-validator/ajv) and only write schemas.The issue we currently have is that Typescript definitions are basically worthless as soon as external data comes into play (such as JSON file sources), and we can still encounter runtime type errors. We could use some generators such as typescript-json-schema or ts-json-schema-generator but I don't know how reliable those are and if they really fit our needs.
At the same time, it almost seems like we're either:
Ideally, we should change the toolchain such that we can support from data source to data output (for instance, using React as (server-side?) template engine would allow us to discover types in context). We could use any of the above libraries to ensure that JSON sources are valid. Or we could ditch type-checking altogether and greatly simplify the code, at the expense of letting the runtime safely escape errors (which would either be caught by Node anyway, or that would simply omit data in templates if they're incomplete).
At the very least, moving to
ajv
would probably make things a lot cleaner alreadyThe text was updated successfully, but these errors were encountered: