Comments (8)
@Hookyns you're blazingly fast! )))
Thanks a lot, will take a look.
from tst-reflect.
@Hookyns confirmed!
Thanks a lot!
Great lib, really like the idea, will see if I can use it for my use case (ORM schema definition via TS)
from tst-reflect.
Hello,
kind Container
is mainly for type operations such as Union and Intersection (Type1 | Type2 & Type3), it is not intended for enums, but yeah, it makes sense it fell to this kind.
I think I haven't test enums yet; I think the new Enum
kind will be needed with new special handlers for that.
Now it generates
___tst_reflect.Type.store.set(21838, {k: 6, n: "", v: 0});
___tst_reflect.Type.store.set(21839, {k: 6, n: "", v: 1});
___tst_reflect.Type.store.set(21837, {
k: 3,
types: [___tst_reflect.Type.store.get(21838), ___tst_reflect.Type.store.get(21839)],
union: true,
inter: false
});
Which is union of literals. There are values but no names,.. its under Type.types
What do you expect in Enum Type?
- name of the enum
- and enum itself? Or list of entries (
[ {property: "Single", value: 1}, { ... } ]
) or simple object ({ "Married":0, "Single":1 }
)?
Enum is transpiled as:
var SomeEnum;
(function (SomeEnum) {
SomeEnum[SomeEnum["One"] = 0] = "One";
SomeEnum[SomeEnum["Two"] = 1] = "Two";
})(SomeEnum || (SomeEnum = {}));
which gives you everything.. so reference to that enum should be enough.
from tst-reflect.
indeed, reference to enum sounds good, but a discriminator is required to know it's an enum (maybe TypeKind.Enum
?)
from tst-reflect.
Okay, I've pushed implementation into same branch (https://github.com/Hookyns/ts-reflection/tree/feature/refactored-stores
).
There is no reference to the real enum, it was quite problematic, because those enums can be in private modules (not exported) etc. and the enums would be useless without references.
So I add
Enum
kind,Type.isEnum(): boolean
,Type.getEnum(): EnumInfo
EnumInfo:
interface EnumInfo
{
/**
* Get enum enumerators/items (keys).
*/
getEnumerators(): string[];
/**
* Get values.
*/
getValues(): any[];
/**
* Get enum entries (key:value pairs).
*/
getEntries(): Array<readonly [enumeratorName: string, value: any]>;
}
from tst-reflect.
I've published new versions of packages with implementation:
[email protected]
[email protected]
from tst-reflect.
I thank you for this issue!
Feel free to create another issues if you find something. 🙂
from tst-reflect.
just did 😄
from tst-reflect.
Related Issues (20)
- 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
- Generic Type at runTime 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.