Comments (6)
also capturing decorator args would be really great (primitives & enums)
class Entity {
@Orm.Id(Orm.IdKind.AutoGenerated)
id: string;
}
from tst-reflect.
also capturing decorator args would be really great (primitives & enums)
class Entity { @Orm.Id(Orm.IdKind.AutoGenerated) id: string; }
This is related with #7
There is no problem to support property decorators and allow them to get type of class via generic type. So it is possible to start from other side from that decorator, with all the runtime arguments of that decorator and get type of class. That's the point in #7.
Your point is good too. If it is constant value, capture it.
So add Decorator.arguments: any[]
?
from tst-reflect.
Decorator.arguments: any[]?
Sounds good 👍
Thanks
from tst-reflect.
Fixed. Will be publish with other bug fixes in next version.
Contains fix of the decorators from different module and getArguments(): Array<any>
on decorators.
Arguments must be Literal
(string, number, boolean or enum. It can be value from const
variable, even imported).
It is possible to allow Object litrals too, but it's a little tricky... I've kept it simple for this time...
import {
getType,
reflect
} from "tst-reflect";
import { SomeEnum } from "./SomeEnum";
import { SomeString } from "./SomeType";
const MyString = "SomeType";
function klass<TType>(str: string, num: number, enu: SomeEnum)
{
console.log("klass", str, num, enu, getType<TType>());
return function <T>(Constructor: { new(...args: any[]): T }) {
};
}
function property(str: string, num: number, enu: SomeEnum, any: any)
{
console.log("property", str, num, enu, any);
return function (_, __) {};
}
@klass(MyString, 5, SomeEnum.One)
class A
{
@property("Foo property", 5, SomeEnum.One, { foo: "f", bar: 5, baz: SomeEnum.Two })
foo: string;
@property(SomeString, 5, SomeEnum.Two, true)
get bar(): number
{
return 0;
}
}
from tst-reflect.
Available from:
[email protected]
[email protected]
Version details in CHANGELOG
from tst-reflect.
awesome!
thanks @Hookyns
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 52
- [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.