-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Participation in the new version of the system #78
Comments
I am excited to see the new version of this library. I am willing to participate in the alpha of the new major version. |
Hi, I want to investigate the potential of this library and would be happy to participate |
Sign me up. I've been testing doing recursive model hydration with data from the Jira API. So far it looks very promising with the exclusion of one bug with getCtor but that looks like its been flagged as fixed in v1. I'd be happy to run the alpha through my use case. |
Looking to see if I can leverage this for my Remix project. There's an issue with transmitting the class from backend to the front end via the useLoaderData(). I'm hoping to leverage this to send the meta data along so when it gets to the other side the class/object can be reconstructed. |
I would like to be able to help with the alpha version. I was looking to use this package for generic classes which does not seem to be possible in the current version but will be in the new version (#30). My use case being to help create documentation from the actual source code to produce 'live' docs rather than manually documenting things. |
i would to be able to use alpha on this |
Hi guys, TY for your interest! 🎉 I'm late with the alpha, working hard on it. 🏭 I've already prepared website and documentation (first basic version). Project will remain private for a while, I'll invite you into the organization and send you link to discord server, so you can get proper support and I can get some feedback I hope. 🙂 |
Hi! I'd love to participate in the alpha :) |
Late (again), but it will be this week. 🎉 I'm stucked on one strange issue caused by strange conditions. I'm finally able to reproduce it. Now I have to fix it. |
I was just looking at another repo for something else and it has a link to moddle. It might be of use to this project or someone else looking to reconstruct JSON to object. In my case I needed a way to convert an object to JSON and send it across the wire. Then reconstruct the object once it arrives on the client side. |
I'm willing to participate |
I've granted you access to the organization and mentioned you in an issue. |
@Hookyns Please add me to the alpha! |
Great project, thanks for your work @Hookyns! I'd love to join the alpha, too! :) |
First of all thx for your awesome work! You saved me hours of work! I would like to join the alpha too! |
Hi, I'd love to participate in the alpha! |
Hey! I'd also like to join the alpha :) |
Count me in! |
Hi! |
Hi, I really like what you are doing, looking for a similar solution for a long time, may I join too? |
Hi, I'm interested in participating as well if it's not too late! |
@nduc For that purpose, you may be interested in I'm also working on its companion library |
Hi, I'm interested in participating too if possible ! |
Is this project still happening? If so, I'm also interested. I have extensive experience with reflection in PHP and C#, if that matters - I've written DI containers in both languages, and I also wrote one of the earliest annotation libraries for PHP. Where I'm stuck with TypeScript is there seems to be no good approach to dependency injection containers without reflection - I've spent years on-and-off trying to solve this with types, I've looked at every DI container with types, and it just doesn't seem feasible. I started tinkering with deepkit.io and I don't find their reflection approach at all useful. So yeah, quite interested in testing this. :-) |
Sure! 🙂 DI was the main reason why I started to work on this. |
Yeah, a DI container is the main reason I want reflection too. My ideas about a DI container is quite different from the "main stream" - quite a lot of non-features. I wrote at least 5 DI containers before settling on this. 😅 |
As we discussed earlier, Typegen is completely standalone tool which just take .ts files as input and generate static metadata library (I call it a typelib) as output; it's not part of the build process. It's based on alpha's transformer. I just had to create the tool and rewrite some parts, it took just about 4 weeks of work and I'm a week behind with the prototype against expectations. 🤷 It's rly just a prototype. It only generate the typelib which you can use statically ( I need at least another month to get it into alpha phase. |
oh, okay, I thought you were trying to say you had come up with a solution. so it's still going to be a limited version for SWC and ESBuild. I'm still not sure if I think this is a good idea. I mean, imagine you ship something like a DI container or router that depends on this runtime, and you're showing cool examples like and I understand why it's the best we can do. but I still wonder if maybe it would be possible to integrate the official TS compiler into something like Vite... I guess if all of these tools are designed to work file-by-file, it's just not going to be possible? man, that's so frustrating. 😔 |
I think I have a possible solution for this too but I don't know what the performance will be. It may be even worse than switching to plain old tsc. But it's not a priority for me. I think that the planned supported features (for swc and esbuild) will be sufficient for about 50 % of use-cases which is still infinitely more than what's possible now. 🙂 And you can still say that users have to enable strict mode (noImplicitAny to be specific), then it will work without any issues. But it will have a solution in the future thanks to Donny's STC. EDIT: class SomeService {
constructor(logger: ILogger, router: Router, somethingElse: SomethingElse) {}
orMethodInjection(something: ISomething) {}
} with registration like (super simple & naive implementation): import { Metadata } from "./metadata.typelib";
class ServiceCollection {
addSingleton(serviceType: Type, serviceImplementation: Type): void {}
addTransient(serviceType: Type, serviceImplementation: Type): void {}
}
const sc = new ServiceCollection();
const serviceImplementations = Metadata.getTypes().filter(t => t.isClass() && !t.isAbstract() && t.name.endsWith("Service"));
for (let implementation of serviceImplementations) {
sc.addTransient(implementation.implements.find(i => i.name.endsWith("Service")) , implementation);
} There is no need to infer anything. |
Here is a preview with esbuild, using the new Typegen and esbuild plugin. Typegen is still a prototype (pre-alpha version) and the esbuild plugin is just a proof of concept, but I progress quickly. |
Hi! Amazing job! I would love to give a try to the alpha version :) |
Hello, I'm developer of typia, and wanna see how |
Great work 🙌 I also want to join the alpha channel👀 |
I'd like to participate =) |
Hi, I'm interested in participating. |
Please, I would like to test. 😄 |
Please, I want it too |
Hi, I too have a very burning interest in such a thing |
Hey, thanks a lot for this project! Sign me up for the alpha too please, if you need contributors I'm willing to contribute too 😄 |
Hi @Hookyns I would be interested to participate and contribute. I'm the author of https://mion.io/ Good Job 🚀⭐️ |
Hello guys, I'll make the repo public soon. You can visit rttist.org and docs. Post your feedback. Here is the latest demo. PS: I will greatly appreciate a PR to improve the docs! |
Can I try out the alpha version? |
Sign me up! |
Would you please include me? Thanks! |
Hi, can you please invite me? |
Can I also join in? Thank you! |
@Hookyns, count me in please👍 |
Looking forward to checking out the new version 🔥 |
Can I use this to generate Teal types from TS ones? (Writing my own generator) I so, please add me to the repo. Otherwise, if you know of any tool I can use for this task please tell me. Thanks! |
Hello @Papipo, I created a demo of such generator for you. In the |
Amazing! Can I get access to the repo? Thanks! BTW, how does this lib compare to ts-morph? I have been using it but I think the DX is not as pleasant as it could be. |
ts-morph is wrapper for TS compiler API. It helps you manipulate the TS source code. With RTTIST you do nothing with the source code, I do that for you; I traverse the TS code, handle different TS versions, find all types, all their properties, methods, decorators etc. and I create one file with metadata about all the types. Then I provide you runtime API you can use to read that metadata file. So you will use RTTIST cli that will generate metadata from a TS project and you can work with it at runtime. It's typical reflection as you may know from eg. C#, Java, Go etc. With this, you can access metadata about all the types in the project: const allTypesInWholeProject: Type[] = Metadata.getTypes(); So you can write a node.js script that will read your TS project, you'll receive all the TS metadata and you can just generate LUA files using the node:fs API. Bit more info in the docs. Still WIP. Definition of Type and Module and eg. base Object type (Taken from .d.ts inside rttist package. Not documented yet.)class ObjectLikeTypeBase extends Type {
/**
* Returns array of properties.
*/
getProperties(): ReadonlyArray<PropertyInfo>;
/**
* Returns property matched by name.
*/
getProperty(name: string | number | symbol): PropertyInfo | undefined;
/**
* Returns array of indexes.
*/
getIndexes(): ReadonlyArray<IndexInfo>;
/**
* Returns array of methods.
*/
getMethods(): ReadonlyArray<MethodInfo>;
/**
* Returns method matched by name.
*/
getMethod(name: string | number | symbol): MethodInfo | undefined;
}
class MethodInfo {
/**
* Name of the method.
*/
get name(): MemberName;
/**
* Method is optional.
*/
get optional(): boolean;
/**
* Access modifier.
*/
get accessModifier(): AccessModifier;
/**
* Returns array of decorators.
*/
getDecorators(): ReadonlyArray<DecoratorInfo>;
/**
* Returns array of method signatures.
*/
getSignatures(): ReadonlyArray<SignatureInfo>;
toString(): string;
}
class SignatureInfo {
/**
* Return type of the method.
*/
get returnType(): Type;
/**
* Returns parameters of the signature.
*/
getParameters(): ReadonlyArray<ParameterInfo>;
/**
* Returns array of type parameters.
*/
getTypeParameters(): ReadonlyArray<TypeParameterType>;
toString(): string;
}
class ParameterInfo {
/**
* Name of the parameter.
*/
readonly name: string;
/**
* Parameter is optional.
*/
readonly optional: boolean;
/**
* Parameter is the rest rest parameter.
*/
readonly rest: boolean;
/**
* Type of the parameter.
*/
get type(): Type;
/**
* Returns array of decorators.
*/
getDecorators(): ReadonlyArray<DecoratorInfo>;
toString(): string;
}
class Type {
static readonly Invalid: Type;
static readonly NonPrimitiveObject: Type;
static readonly Any: Type;
static readonly Unknown: Type;
static readonly Void: Type;
static readonly Never: Type;
static readonly Null: Type;
static readonly Undefined: Type;
static readonly String: Type;
static readonly Number: Type;
static readonly BigInt: Type;
static readonly Boolean: Type;
static readonly True: Type;
static readonly False: Type;
static readonly Date: Type;
static readonly Error: Type;
static readonly Symbol: Type;
static readonly UniqueSymbol: Type;
static readonly RegExp: Type;
static readonly Int8Array: Type;
static readonly Uint8Array: Type;
static readonly Uint8ClampedArray: Type;
static readonly Int16Array: Type;
static readonly Uint16Array: Type;
static readonly Int32Array: Type;
static readonly Uint32Array: Type;
static readonly Float32Array: Type;
static readonly Float64Array: Type;
static readonly BigInt64Array: Type;
static readonly BigUint64Array: Type;
static readonly ArrayDefinition: Type;
static readonly TupleDefinition: Type;
static readonly ReadonlyArrayDefinition: Type;
static readonly MapDefinition: Type;
static readonly WeakMapDefinition: Type;
static readonly SetDefinition: Type;
static readonly WeakSetDefinition: Type;
static readonly PromiseDefinition: Type;
static readonly GeneratorDefinition: Type;
static readonly AsyncGeneratorDefinition: Type;
static readonly IteratorDefinition: Type;
static readonly IterableDefinition: Type;
static readonly IterableIteratorDefinition: Type;
static readonly AsyncIteratorDefinition: Type;
static readonly AsyncIterableDefinition: Type;
static readonly AsyncIterableIteratorDefinition: Type;
static readonly ArrayBuffer: Type;
static readonly SharedArrayBuffer: Type;
static readonly Atomics: Type;
static readonly DataView: Type;
static readonly Type: Type;
static readonly Module: Type;
/**
* Type identifier.
*/
get id(): TypeIdentifier;
get displayName(): string;
/**
* Kind of the type.
*/
get kind(): TypeKind;
/**
* Module which declare type represented by the this Type instance.
*/
get module(): Module;
/**
* Name of the type.
*/
get name(): string;
/**
* Type is exported from its Module.
*/
get exported(): boolean;
/**
* Type has iterator, is iterable.
*/
get iterable(): boolean;
/**
* Type is nullable so null and undefined are valid values for the type.
*/
get nullable(): boolean;
/**
* Definition of the generic type.
* @internal Hidden in Type; Should be visible only by GenericTypeDefinition<>.
*/
get genericTypeDefinition(): GenericType<Type> | undefined;
/**
* Returns true if type is equal to type passed as type argument.
*/
is<T>(): boolean;
/**
* Returns true if types are equal.
* @param target
*/
is<TType extends Type>(target: TType): target is TType;
/**
* Returns array of generic type arguments.
* @internal Exposed by {@link GenericType}.
*/
getTypeArguments(): ReadonlyArray<Type>;
/**
* Check whether the type is generic.
*/
isGenericType(): this is GenericType<typeof this>;
/**
* Check whether the type is definition of the generic type.
*/
isGenericTypeDefinition(): this is GenericType<typeof this>;
/**
* Check whether the type is generic type parameter.
*/
isTypeParameter(): this is TypeParameterType;
/**
* Returns a value indicating whether the Type is container for unified Types or not.
*/
isUnion(): this is UnionType;
/**
* Returns a value indicating whether the Type is container for intersecting Types or not.
*/
isIntersection(): this is IntersectionType;
/**
* Returns a value indicating whether the Type is a class or not.
*/
isClass(): this is ClassType;
/**
* Returns a value indicating whether the Type is a interface or not.
*/
isInterface(): this is InterfaceType;
/**
* Returns a value indicating whether the Type is a interface or not.
*/
isTypeAlias(): this is TypeAliasType;
/**
* Returns a value indicating whether the Type is an literal or not.
*/
isLiteral(): this is LiteralType;
/**
* Returns true if type is union or intersection of types
*/
isUnionOrIntersection(): this is UnionType | IntersectionType;
/**
* Check if this type is an Array.
*/
isArray(): this is ArrayType;
/**
* Check if this type is a Tuple.
*/
isTuple(): this is TupleType;
/**
* Determines whether the object represented by the current Type is an Enum.
* @return {boolean}
*/
isEnum(): this is EnumType;
/**
* Determines whether the object represented by the current Type is an Conditional type.
* @return {boolean}
*/
isConditional(): this is ConditionalType;
/**
* Determines whether the object represented by the current Type is an object-like type.
*/
isObjectLike(): this is ObjectLikeTypeBase;
/**
* Determines whether the object represented by the current Type is an Object type.
*/
isObject(): this is ObjectType;
/**
* Determines whether the object represented by the current Type is an Template type.
*/
isTemplate(): this is TemplateType;
/**
* Determines whether the object represented by the current Type is a Function type.
*/
isFunction(): this is FunctionType;
/**
* Determines whether the object represented by the current Type is one of the predefined ES symbols.
*/
isESSymbol(): this is ESSymbolType;
/**
* Determines whether the object represented by the current Type is an unique symbol.
*/
isUniqueSymbol(): this is UniqueSymbolType;
/**
* Returns true whether current Type is instantiable.
*/
isInstantiable(): boolean;
/**
* Check if this is a primitive type ("string", "number", "boolean" etc.).
*/
isPrimitive(): boolean;
/**
* Check if this type is a string.
*/
isString(): boolean;
/**
* Check if this type is a number.
*/
isNumber(): boolean;
/**
* Check if this type is a bigint.
*/
isBigInt(): boolean;
/**
* Check if this type is a boolean.
*/
isBoolean(): boolean;
/**
* Check if this type is an "any".
*/
isAny(): boolean;
/**
* Check if this type is an "never".
*/
isNever(): boolean;
/**
* Check if this type is an "void".
*/
isVoid(): boolean;
/**
* Check if this type is an "undefined".
*/
isUndefined(): boolean;
/**
* Check if this type is an "null".
*/
isNull(): boolean;
/**
* Returns string representation of the type.
* @returns {string} Returns string in format "Kind{fullName}"
*/
toString(): string;
} class Module {
/**
* Module for all the native types.
*/
static readonly Native: Module;
/**
* Module for dynamic types without specific module.
*/
static readonly Dynamic: Module;
/**
* Unknown module.
*/
static readonly Invalid: Module;
/**
* The name of the module.
* @description It is filename of the module in the most of the cases.
*/
readonly name: string;
/**
* The path of the module.
*/
readonly path: string;
/**
* Module identifier.
*/
get id(): ModuleIdentifier;
/**
* Returns array of modules required by this Module.
* @description These are all the imported modules.
*/
getChildren(): ReadonlyArray<Module>;
/**
* Returns array of types from the module.
*/
getTypes(): ReadonlyArray<Type>;
/**
* Imports module and returns exported object.
*/
import(): Promise<undefined | {
[exportName: string]: any;
}>;
} |
I see there is in progress support for vite. In fact my use case is with Vue SFCs: I am writing the UI of a game using them and I want to grab its Props interface to aid in the development of the backend game rules, which will be written in Teal. So right now I am using |
@Papipo Does it have to be "real-time"? I mean, does it have to be generated with the HMR/fast-reload while you develop your Vue app? Or can it be CLI tool that you'll run here and there? Can you prepare some demo project on StackBlitz? How does your components look like, how the props are defined and what the output should be? |
For now I am going with a CLI but honestly I thought about using a watcher at some point. Not sure if I will be coding both the FE at the same time, but it might happen. For now the approach is to code the FE in Vue, as I can use storybook or in general fake payloads, and only then, transform the entry point Props interface into Teal types to start coding the backend, but we'll see (the project is a year old but only now I've decided to go this route). After all, it's the FE who dictates what props it needs. I'll try to give you a sample repo but that'll have to wait at least a week because I am on vacation for the rest of the week. BTW, if you are curious, I plan to use Elixir for the host app, Luerl (an implementation of lua to be run in the BEAM) to run the game engine/rules (lua via teal compiler) and LiveVue to update the Vue props via a websocket (hence the requirement to transform types, for pure sanity). We'll see if it works as intended 😅 |
Sign here who wants to participate in the alpha of the new major version. I will invite you to the private project when it is ready. 🎉
The text was updated successfully, but these errors were encountered: