labeg / first-di Goto Github PK
View Code? Open in Web Editor NEWEasy dependency injection for typescript applications
License: MIT License
Easy dependency injection for typescript applications
License: MIT License
На проекте мы не используем классы - только модули
Injected with @autowired()
objects are undefined
Trying to use this lib as described in readme, but got this error on build time:
> Build error occurred
/node_modules/first-di/dist/index.js:1
export * from "./classes/di";
^^^^^^
SyntaxError: Unexpected token 'export'
WARNING:
export 'reflection' (imported as 'reflection') was not found in 'first-di' (possible exports: autowired, instance, override, reset, resolve, singleton)
ERROR in ./node_modules/first-di/dist/index.mjs 3:0-45
Module not found: Error: Can't resolve './models/autowired-lifetimes' in '...\node_modules\first-di\dist'
Did you mean 'autowired-lifetimes.js'?
BREAKING CHANGE: The request './models/autowired-lifetimes' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '.mjs' file or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
@autowired()
private readonly myService!: AService;
private readonly myStr: string;
constructor() {
this.myStr = "test";
}
public foo():string {
return this.myService.getObj();
}
Call of foo
method returns string
this.myService
is undefined insade foo
method
@autowired()
private readonly myService!: AService;
private readonly myStr: string;
constructor() {
this.myStr = "test";
}
public foo():string {
return this.myService.getObj();
//TypeError: Cannot read properties of undefined
}
Steps to reproduce behavior:
useDefineForClassFields: true
in tsconfig.jsonA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.