Comments (5)
esbuild states that it doesn't support Decorator Metadata: https://esbuild.github.io/content-types/#no-type-system so I'm not sure how you're getting it to work with that? do you have a transformation step beforehand?
Tried removing it and relying on the new stage 3 decorators, available in TS 5.0: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#decorators but I get warnings that I can't use @Inject within a constructor:
constructor(
@Inject(APP_CONFIG) private appConfig: AppConfig,
) {}
I'm guessing to use stage 3 I'd need to refactor that to look like this?
constructor() {
this.appConfig = Container.get(APP_CONFIG);
}
When I look at the spec for stage 3 decorators: https://github.com/tc39/proposal-decorators#access-and-metadata-sidechanneling
It looks like this sort of thing would be supported but I'm not sure if TypeDI supports that? or if stage 3 are supported at all?
export class MyService {
@Inject(APP_CONFIG) private appConfig: AppConfig;
constructor() {...}
}
Was hoping to use esbuild to speed up build times but constantly running into new walls and the information is so sparse on the subject of modules, decorators etc. This is the frustrating thing when relying on specs that can change... we're stuck in the transition period where I don't really know what's happening, what's working, what's supported or how.
It would be great if typedi could add a notice explaining if it depends on stage 2
from typedi.
typedi 0.8.0, typescript 4.7.4 + esbuild works ok for me on a project.
There are many breaking changes in 0.9.0 - https://github.com/typestack/typedi/blob/develop/CHANGELOG.md#090---20210110
from typedi.
And this is why we've switched most of our project to alternative DI libraries.
from typedi.
And this is why we've switched most of our project to alternative DI libraries.
What are those alternatives? I'm looking for a good DI library for JS/TS, but most seem to be unmaintained at this point.
from typedi.
And this is why we've switched most of our project to alternative DI libraries.
What are those alternatives? I'm looking for a good DI library for JS/TS, but most seem to be unmaintained at this point.
Well, after being a bit miffed about TypeDI, I ended up making a fork: https://github.com/freshgum-bubbles/typedi. I'd say it's pretty feature complete. The API is still technically in beta stage, but it's just a matter of ironing out the interface and adding more features on top of Typestack's TypeDI. It's feature-complete, of course, and I've written up a documentation site for it too: https://typedi.js.org/
from typedi.
Related Issues (20)
- question: How do you test your services with dependency injection? HOT 32
- fix: Constructor Injection fail in vitest/jest HOT 3
- question: adding custom proxy traps in class constructors and instances HOT 2
- fix: non-reconstructable services are erased when imported HOT 1
- question: Stage 3 decorator support (available since TS 5.0)
- question: How to debug circular dependency injections ?
- Question: Service Injection working incorrectly HOT 1
- question: is this project/repo dead? HOT 5
- question: <Implementing repository injection using typedi-typeorm.> HOT 3
- question: <Is it possible to adapt your DI to work with modules (not classes)?> HOT 1
- question: HOT 3
- fix: not working function dependency injection examples from docs HOT 3
- question: Inject Private Property HOT 2
- Using ContainerInstance in the service constructor causes TypeScript build breaks HOT 1
- question: identifier was not found in the container HOT 2
- question: Using typedi with monorepo HOT 3
- question: Using Typedi with Vite - Returning ContainerInstance2 HOT 3
- question: How to define a third-party dependency HOT 5
- question: Using Token with Generics failed in stongly typying
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typedi.