Looking for a way of doing TypeScript validation of static files

Hi fellow typesafe cultists. I have a project with a lot of POJO-style data which I need to: 1) keep in version control (the data gets updated fairly regularly, they're game data files so with each playtest they change, but I want the ability to revert) 2) keep strictly typed (and if possible have autocomplete/error highlighting while editing them) Right now, this data is stored in typescript files, which fulfills both requirements... But, doing it this way bloats the client bundle even when the user only needs 1% of it. I don't think using a database would be a good idea here, as this would only fulfill the second requirement. The ideal would have been for me to find a VSCode extension or command line tool, which would allow me to do type checking in JSON files, but I haven't been able to find a tool like this. The only alternative I can think of right now would be to somehow generate an XSD file as a build step, from my typescript/zod schemas, and then store my data in XML files. Before I start doing something silly, and waste potentially a couple days of work over this, I wanted to ask - is there a better way to do this that I'm just not aware of?
2 Replies
chip
chip7mo ago
You could use a JSON schema
michaeldrotar
michaeldrotar7mo ago
I don't see the connection between storing the data in a typescript file and needing to bloat the client bundle. If a database solves your concerns here, couldn't you treat the typescript file like a database? Create an api route to query against it and only return the 1% to the browser that's needed?
Want results from more Discord servers?
Add your server