--

This doesn't really have much to do with Typescript--it would work the same if you weren't using TS. ServiceLocator only helps some--you're still using es6 to import a specific implementation. It's better to use dependency injection to provide your dependencies, rather than have your classes reach out and grab them (even with the help of a serviceLocator).

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

No responses yet