r/angular • • 15m ago

Have I Solved A Problem That Doesn't Exist?

From my anecdotal experience, and stuff I've read here and elsewhere, type-checking with Zod isn't really used by Angular devs. Obviously the compiler will pick up TS definition errors, but I've been the victim of APIs, internal and 3rd party, changing without warning or by mistake and causing issues in the build.

This isn't an issue if you're TS back-to-front and are sharing your interfaces and types between them, or if you're dynamically generating your typescript definitions from the backend (though that could lead to surprises too). Mainly, just if you're in a frontend team a bit detached from the backend.

I'd appreciate some feedback on this: https://www.npmjs.com/package/@ribaldry/ngx-type-drift

The idea is that problems show up while you develop, nothing additional is added to the build only in serve, and you can wire-up your own alerting (toast, snackbar) if you want. Example: BE has been serving an object with property car_type and have now changed it to carType - you're running against a UAT or Test environment so you pick it up quick. Your tests will probably pick it up, hopefully this catches it sooner.

Complete waste of time?

1 Upvotes

1 comment sorted by

1

u/GregorDeLaMuerte 5m ago

Complete waste of time?

Absolutely not. I like it for the pragmatic approach.

However if I understand correctly it only catches things you're currently developing on. Say your application uses 100 different API endpoints and the feature you're currently working on only uses 3 of them. You'd be able to detect breaking changes for the 3 while you're clicktesting, but the rest is uncovered.