import { getType , Type } from "tst-reflect" ; import "./metadata.lib" ; function inferType < TType > ( ) { return getType < TType > ( ) . name ; } const val = 5 ; console . log ( inferType < typeof val > ( ) ) ; interface ILogger { } abstract class LoggerFactory { param categoryName createLogger < TCategory = undefined > ( ... categoryName ) { const type = getType < TCategory > ( ) ; console . dir ( type ) ; const category = categoryName ?. [ 0 ] ?? type ?. name ; console . log ( category ) ; return { } ; } } class DefaultLoggerFactory extends LoggerFactory { } class Builder { build ( ) { return new DefaultLoggerFactory ( ) ; } } class SomeType { array : Array < { foo : string ; bar : string ; } > = [ ] ; } const factory = new Builder ( ) . build ( ) ; factory . createLogger < { foo : string ; bar : "a" | "b" ; } > ( ) ; factory . createLogger < [ fo : string ] > ( ) ; factory . createLogger < SomeType > ( ) ; class Foo { prop : number ; constructor ( prop ) { this . prop = prop ; } } const variable = new Foo ( 5 ) ; console . log ( getType < Foo > ( ) ) ; console . log ( getType < typeof variable > ( ) ) ;