Git Product home page Git Product logo

Comments (5)

Hookyns avatar Hookyns commented on July 26, 2024 1

@avin-kavish

  1. You can. https://github.com/Hookyns/tst-reflect/blob/main/tests/src/11-generic-class-decorator.ts @classDecorator
  2. 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.

Hookyns avatar Hookyns commented on July 26, 2024

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.

avin-kavish avatar avin-kavish commented on July 26, 2024

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.

Hookyns avatar Hookyns commented on July 26, 2024

@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.

avin-kavish avatar avin-kavish commented on July 26, 2024

that's great!

I was considering the following about tst-reflect usage,

  1. 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 {}
  1. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.