Comments (2)
Hey there,
So, I do have several questions based on your issue here.
- You use a method called
load
, but this library uses constructor injection. Did you mean to use the constructor? - You use a type annotation,
generic
, but neither theload
method nor the interface itself is generic. Which one is it?
Something that is now possible in v2.2.1 that wasn't possible before is to provide type arguments when declaring a service and its implementation:
interface MyInterface<T> {
}
container.registerSingleton<MyInterface<boolean>, MyClass>();
container.registerSingleton<MyInterface<boolean>, MyClass>();
Before, the compiler would assume that you wanted MyClass to only implement the service specifically called MyInterface<boolean>
whereas now the service name is still just MyInterface
.
from di-compiler.
FYI - type with generics (ie, IFoo<IBar>
) work for registerSingleton
and registerTransient
but they do not work correct with get
. The type is not stripped from the generated get
call, leaving the full generic rather than just IFoo
(in the example prior).
The issues appears to be here where:
node.typeArguments[0].getFullText().trim()
likely needs to be:
node.typeArguments[0].getFirstToken()!.getFullText().trim()
That change appears to work for me, though in the process I did notice that the tests extensively test the register calls, but do not do the same for get (and I don't think they cover types, but I didn't search all tests).
from di-compiler.
Related Issues (18)
- Issues with derived classes transpiled by Typescript HOT 1
- Jest example HOT 1
- Does not work with webpack ts-loader HOT 4
- Does this work with @rollup/plugin-typescript ? HOT 3
- Is there any special compiler options required? HOT 1
- Usage with Vite.js HOT 2
- Is there a way to get compilation error when the service is not registered at all?
- Extended services without constructors doesn't work. HOT 2
- Support for async service factories HOT 16
- Esbuild plugin support
- JSX support for transform() API method
- ttypescript deprecated and replaced with ts-patch
- ReferenceError: 1 argument required, but only 0 present HOT 6
- DI-compiler fails to build due to change in TypeScript and @wessberg/ts-config
- Build a graph to discover cyclic dependencies and automatically apply proxies to defeat them HOT 1
- Bindings not generated with Parcel HOT 1
- is it possible to use with babel/preset-typescript ? HOT 1
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 di-compiler.