News for hackers. Stuff that matters.
Re:Not Sucking at TypeScript: 3 Tips by jeremychone on Saturday September 22, 2018 @06:10PM (#18048280)
Honestly, DI is really a thing of the OO-Obsessed world when everything has to be a class and instantiated.

In the JS/TS world, we mostly use Interface/Type to describe constraints, and most of the module export function or group of methods in a const (namespace, module,...) but the caller does not have to know if it is a class or just a object with some methods, and does not do a "new ..." or @inject... anymore. Much simpler, much more intent driven, and you can remove a lot of boilerplate code (which DI still is)

Now, one of the value of DI is for testing, and one way to accomplish module compartmentalization, is with module-alias. It does not the granularity that DI needs, but I would argue that if more is needed, it perhaps because the testing and mocking got a little too out of hands. In our experience, thanks to Kubernetes, we try to mock less, and have our test running mostly with real services.

There are no comments on this comment yet.