Comments (5)
- You can. https://github.com/Hookyns/tst-reflect/blob/main/tests/src/11-generic-class-decorator.ts
@classDecorator
- Now all the types passed to
getType<T>()
and types decorated by decorators marked by@reflect
are "reflected".
Next
version is prepared for generating metadata about all the modules and types.
It's in progress and the latest progress is private until publish of final version.
from tst-reflect.
Fixed in [email protected]
But type
work differently than other generic types. type
is resolved to it's definition. So type Foo<T> = T & {}
is just union T & {}
, cuz Foo
does not rly exist.
Check this StackBlitz out.
from tst-reflect.
thanks for the fix!
While I'm here, isn't it possible to get types from the reference to a class ? i.e. getType(Foo)
instead of getType<Foo>()
from tst-reflect.
@avin-kavish
It is now in [email protected]
.
It was possible to get type of value getType(new Foo())
; just one line and you are able to get type of class itself getType(Foo)
.
from tst-reflect.
that's great!
I was considering the following about tst-reflect
usage,
- Can't we use a decorator directly, without having to call a method that returns a decorator?
/**
* @reflect
*/
function inject<TType extends Constructor>(ctor: TType) {
const typeInfo = getType<TType>()
}
// usage
@inject
class Foo {}
- Can't we collect type info for all classes/interfaces in a project without using decorators? Maybe it's too slow?
from tst-reflect.
Related Issues (20)
- Add support of `isDefaultValueAvailable` and `getDefaultValue` on PropertyInfo and Parameter types HOT 6
- Support decorators from TS 4.8 HOT 2
- Unable to access parameter decorators HOT 2
- [BUG] Set not comparable HOT 1
- [Question] Anyway to add it as angular transformer HOT 18
- [BUG] tst-reflect: You call getType() method directly. You have probably wrong configuration, because tst-reflect-transformer package should replace this call by the Type instance. HOT 8
- [BUG] type metadata HOT 6
- Can't get `getType<T>()` to work HOT 5
- Participation in the new version of the system HOT 53
- [BUG] Watch mode HOT 1
- Can't get function to work with create-react-app HOT 3
- [BUG] Uncaught ReferenceError: _ßr is not defined HOT 4
- [Question] npm package using tst-reflect cannot be imported HOT 1
- [BUG] Union properties are broken HOT 5
- [BUG] TS 4.9 - "[ERR] tst-reflect: You call getType() method directly..." error when following base usage examples. HOT 17
- [Question] Comparison of Array types HOT 9
- [Question] How to get field type inside a decorator HOT 2
- [Question] Vite support HOT 3
- [Question] Does this work with functions? HOT 2
- Is there a way to use it with nestjs [Question] 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 tst-reflect.