{"id":20366575,"url":"https://github.com/hookyns/tst-reflect","last_synced_at":"2025-04-13T00:46:25.301Z","repository":{"id":37580567,"uuid":"303842776","full_name":"Hookyns/tst-reflect","owner":"Hookyns","description":"Advanced TypeScript runtime reflection system","archived":false,"fork":false,"pushed_at":"2023-07-22T07:06:35.000Z","size":1149,"stargazers_count":351,"open_issues_count":14,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-13T00:46:19.624Z","etag":null,"topics":["dependency-injection","dotnet","generic","javascript","nodejs","plugin","reflection","rtti","rttist","runtime","runtime-reflection","runtime-type-info","runtime-types","transformer","transformer-plugin","type","type-information","typescript","typescript-transformer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hookyns.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-13T22:27:13.000Z","updated_at":"2025-03-29T04:19:44.000Z","dependencies_parsed_at":"2024-06-18T16:45:54.332Z","dependency_job_id":"4badc6f9-6abb-4391-8c52-71c31a88fd88","html_url":"https://github.com/Hookyns/tst-reflect","commit_stats":{"total_commits":305,"total_committers":7,"mean_commits":43.57142857142857,"dds":0.360655737704918,"last_synced_commit":"cb6d9ffd292b150c1a11a5472e0bed2812f5c8d0"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2Ftst-reflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2Ftst-reflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2Ftst-reflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hookyns%2Ftst-reflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hookyns","download_url":"https://codeload.github.com/Hookyns/tst-reflect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650432,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","dotnet","generic","javascript","nodejs","plugin","reflection","rtti","rttist","runtime","runtime-reflection","runtime-type-info","runtime-types","transformer","transformer-plugin","type","type-information","typescript","typescript-transformer"],"created_at":"2024-11-15T00:25:42.459Z","updated_at":"2025-04-13T00:46:25.278Z","avatar_url":"https://github.com/Hookyns.png","language":"TypeScript","readme":"# JavaScript(/TypeScript) Runtime Types \u0026 Reflection (tst-reflect)\n\n\u003e **The mono repository of TypeScript runtime reflection packages.**\n\n[![tst-reflect](https://img.shields.io/npm/v/tst-reflect.svg?color=brightgreen\u0026style=flat-square\u0026logo=npm\u0026label=tst-reflect)](https://www.npmjs.com/package/tst-reflect)\n[![tst-reflect-transformer](https://img.shields.io/npm/v/tst-reflect-transformer.svg?color=brightgreen\u0026style=flat-square\u0026logo=npm\u0026label=tst-reflect-transformer)](https://www.npmjs.com/package/tst-reflect-transformer)\n[![License MIT](https://img.shields.io/badge/License-MIT-brightgreen?style=flat-square)](https://opensource.org/licenses/MIT)\n![Code coverage](./coverage/badge.svg)\n[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social\u0026label=Follow)](https://twitter.com/hookyns)\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=hookyns\u0026repo=tst-reflect\u0026theme=tokyonight)](https://github.com/Hookyns/tst-reflect)\n\n[Examples](#examples) \n| [Synopsis](#synopsis) \n| [How to start](#how-to-start) \n| [How does it work](#how-does-it-work) \n| [Configuration [wiki]](https://github.com/Hookyns/tst-reflect/wiki/Configuration) \n| [Changelog](https://github.com/Hookyns/tst-reflect/blob/main/CHANGELOG.md)\n| [Contributors](#contributors-)\n\n## Notice!\n\u003e A new version of the entire system is in development!\n\u003e\n\u003e The new version is made up of a separate tool called `typegen` and a new better runtime.\n\u003e It is possible to generate usable metadata even without the need to use any transformer. This metadata can be used manually to lookup types and modules in the project, import the modules, create instances of classes etc. This in not limited to any build system so it is usable with **tsc, Webpack, Vite, esbuild, SWC, Turbopack, Rollup, Parcel** etc.\n\u003e\n\u003e However, there will also be small plugin for each build tool that allow using `getType()` and the generic type parameters, even for SWC and esbuild.\n\u003e Depending on the build system, the functionality of `getType` will vary. Build systems without type checking will not be able to get majority of inferred types eg. `getType\u003ctypeof variable\u003e()`.\n\u003e\n\u003e Sign for participation in the new version [issue #78](https://github.com/Hookyns/tst-reflect/issues/78).\n\n## About\n\nYeap! How the title says, this project is about runtime **reflection**, with working **generic type parameters** `\u003cTSomething\u003e`, \nachieved using custom TypeScript transformer plugin (package `tst-reflect-transformer`) \nand runtime stuff (package `tst-reflect`).\n\n### Features\n- clear Reflection system, generating JS metadata library - can be de facto standard for TS reflection,\n- you can use regular TypeScript,\n- no decorators nor any other kind of hints needed,\n- no problem with the types from 3rd party packages,\n- no pre-implemented features like validators or type-guards, just clear type information. All these features can be built on top of this package in runtime,\n- you can get the runtime type of the generic type, really!\n- you can access the type of the class in your own decorators,\n- you can get the type of a classes, interfaces, type literals, unions, intersections just all of that `getType\u003cSomeType\u003e()`,\n- you can get the type of runtime value stored in variable `getType(myVar)`,\n- object oriented usage - you will get instance of the `Type` class, which contains everything,\n- inspired by the C# reflection - usage is very similar,\n- overloads of a constructors and methods supported,\n- static API to lookup types,\n- access to constructors of all the types - you can instantiate every type,\n- configuration with multiple options,\n- browser usage,\n- you can check if one type is assignable to another without instances of those type - eg. check if some class is assignable to some interface,\n- and there are probably more... and a lot of things are on TODO list.\n\n## How to Get the Type\nUse function `getType\u003cTType\u003e(): Type` imported from module `tst-reflect`.\n\n```typescript\nimport { getType } from \"tst-reflect\";\n\ninterface IFoo {}\nclass Foo implements IFoo {}\n\ngetType\u003cIFoo\u003e();\ngetType\u003cFoo\u003e();\ngetType(Foo);\n\nconst foo = new Foo();\ngetType\u003ctypeof foo\u003e();\ngetType(foo);\n```\n\n### Base Usage\n```typescript\nimport { getType, Type } from \"tst-reflect\";\n\ninterface IAnimal\n{\n    name: string;\n}\n\nclass Animal implements IAnimal\n{\n    constructor(public name: string)\n    {\n    }\n}\n\nconst typeOfIAnimal: Type = getType\u003cIAnimal\u003e();\nconst typeOfAnimal: Type = getType\u003cAnimal\u003e();\n\nconsole.log(typeOfAnimal.isAssignableTo(typeOfIAnimal)); // true\n```\n\n### Get Type of Generic Type Parameter (runtime)\n```typescript\nimport { getType } from \"tst-reflect\";\n\nfunction printTypeProperties\u003cTType\u003e() \n{\n    const type = getType\u003cTType\u003e(); // \u003c\u003c== get type of type parameter TType\n    \n    console.log(type.getProperties().map(prop =\u003e prop.name + \": \" + prop.type.name).join(\"\\n\"));\n}\n\ninterface SomeType {\n    foo: string;\n    bar: number;\n    baz: Date;\n}\n\nprintTypeProperties\u003cSomeType\u003e();\n```\n\nOutput:\n```\nfoo: string\nbar: number\nbaz: Date\n```\n\n### Decorator With Reflected Type Parameter\n\n`tst-reflect-transformer` is able to process class decorators marked by @reflect JSDoc tag.\nYou will be able to get `Type` of each decorated class.\n\n```typescript\n/**\n * @reflect\n */\nexport function inject\u003cTType\u003e()\n{\n    const typeofClass = getType\u003cTType\u003e();\n\n    return function \u003cTType extends { new(...args: any[]): {} }\u003e(Constructor: TType) {\n        return class extends Constructor\n        {\n            constructor(...args: any[])\n            {\n                super(...type.getConstructors()[0].parameters.map(param =\u003e serviceProvider.getService(param.type)));\n            }\n        }\n    };\n}\n\n@inject()\nclass A {}\n\n@inject()\nclass B {}\n```\n\n## How to Start\n\n### Usage With Plain TypeScript\n\n1. Install packages,\n```\nnpm i tst-reflect \u0026\u0026 npm i tst-reflect-transformer -D\n```\n2. add transformer to `tsconfig.json`,\n```json5\n{\n    \"compilerOptions\": {\n        // your options...\n\n        // ADD THIS!\n        \"plugins\": [\n            {\n                \"transform\": \"tst-reflect-transformer\"\n            }\n        ]\n    }\n}\n```\n2. `npm i ttypescript -D`\n\u003e In order to use transformer plugin you need TypeScript compiler which supports plugins eg. package [ttypescript](https://www.npmjs.com/package/ttypescript) or you can use [TypeScript compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API) manually.\n3. Now just transpile your code by `ttsc` instead of `tsc`\n```\nnpx ttsc\n```\n\n### Usage With Webpack\n\n\u003e If you use Angular or something else which has webpack encapsulated and under its own control, \n\u003e this Usage variant may not work properly. \n\u003e Angular has own [Usage](https://github.com/Hookyns/tst-reflect/blob/v0.10/docs/usage/angular.md) description.\n\n#### With `ts-loader`\n\u003e ! `ts-loader` is recommended because you don't need `ttypescript` and it has better performance than `awesome-typescript-loader`.\n\nStackBlitz demo with configured project [here](https://stackblitz.com/edit/tst-reflect-webpack?file=index.ts).\n\n1. Install packages,\n```\nnpm i tst-reflect \u0026\u0026 npm i tst-reflect-transformer -D\n```\n2. modify your webpack config,\n```javascript\nconst tstReflectTransform = require(\"tst-reflect-transformer\").default;\n\nmodule.exports = {\n    module: {\n        rules: [\n            {\n                test: /\\.(ts|tsx)$/,\n                loader: \"ts-loader\",\n                options: {\n                    // ADD THIS OPTION!\n                    getCustomTransformers: (program) =\u003e ({\n                        before: [\n                            tstReflectTransform(program, {})\n                        ]\n                    })\n                }\n            }\n            // ... other rules\n        ]\n    }\n    // ... other options\n};\n```\n3. `webpack` or `webpack serve`\n\n---\n\n#### With `awesome-typescript-loader` (deprecated)\n1. Install packages,\n```\nnpm i tst-reflect \u0026\u0026 npm i tst-reflect-transformer -D\n```\n2. add transformer to `tsconfig.json`,\n```json5\n{\n    \"compilerOptions\": {\n        // your options...\n\n        // ADD THIS!\n        \"plugins\": [\n            {\n                \"transform\": \"tst-reflect-transformer\"\n            }\n        ]\n    }\n}\n```\n3. `npm i ttypescript -D`\n\u003e In order to use transformer plugin you need TypeScript compiler which supports plugins eg. package [ttypescript](https://www.npmjs.com/package/ttypescript) or you can use [TypeScript compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API) manually.\n4. modify your webpack config,\n```javascript\n({\n    test: /\\.(ts|tsx)$/,\n    loader: \"awesome-typescript-loader\",\n    options: {\n        compiler: \"ttypescript\"\n    }\n})\n```\n5. `webpack` or `webpack serve`\n\n### Using Parcel\nInstall Parcel plugin.\n```\nnpm i parcel-plugin-ttypescript\n```\n\n### Using Rollup\nInstall Rollup plugin\n```\nnpm i rollup-plugin-typescript2\n```\nand modify your rollup config.\n```javascript\nimport ttypescript from \"ttypescript\";\nimport tsPlugin from \"rollup-plugin-typescript2\";\n\nexport default {\n    // your options...\n    \n    plugins: [\n        // ADD THIS!\n        tsPlugin({\n            typescript: ttypescript\n        })\n    ]\n}\n```\n\n### Using ts-node\nModify your `tsconfig.json`.\n```json5\n{\n    \"compilerOptions\": {\n        // your options...\n\n        \"plugins\": [\n            {\n                \"transform\": \"tst-reflect-transformer\"\n            }\n        ]\n    },\n    \n    // ADD THIS!\n    \"ts-node\": {\n        // This can be omitted when using ts-patch\n        \"compiler\": \"ttypescript\"\n    },\n}\n```\n_ts-node can be a little bugged if you use `reflection.metadata.type = \"typelib\"` option!_\n\n\n## Examples\n- Listing properties and methods of classes and interfaces [StackBlitz](https://stackblitz.com/edit/tst-reflect-example?file=index.ts)\n- Validace structure of object by interface or class [StackBlitz](https://stackblitz.com/edit/tst-reflect-validate-object-structure-by-type?file=index.ts)\n- Methods and constructors overloads [StackBlitz](https://stackblitz.com/edit/tst-reflect-overloads?file=index.ts)\n- Create object with default values by interface [StackBlitz](https://stackblitz.com/edit/tst-reflect-example-get-default-values?file=index.ts)\n\nDeprecated\n- Simple Dependency Injection [![Run on repl.it](https://repl.it/badge/github/Hookyns/tst-reflect-example-01)](https://replit.com/@Hookyns/tst-reflect-example-01#src/index.ts)\n- Object validation by Interface [![Run on repl.it](https://replit.com/badge/github/hookyns/tst-reflect-validate2)](https://replit.com/@Hookyns/tst-reflect-validate2#src/index.ts)\n\nFeel free to add Your interesting examples. Just add a link to this README and make a PR.\n\n\n## How Does it Work\n\nTransformer looks for all calls of `getType\u003cT\u003e()` and replace those calls by `Type` retrieving logic. It generates object literals describing referred types and instances of `Type`\nare created from those objects.\n\n### Metadata\n\nMentioned object literals describing types are called **metadata**. Default behavior collect metadata of all used types and generate file `metadata.lib.js` in project root (\nlocation of tsconfig.json).\n\nMetadata library file looks like this:\n\n```javascript\nvar {getType} = require(\"tst-reflect\");\ngetType({\n    k: 5,\n    props: [{n: \"foo\", t: getType({n: \"string\", k: 2})}, {\n        n: \"bar\",\n        t: getType({k: 3, types: [getType({k: 6, v: \"a\"}), getType({k: 6, v: \"b\"})], union: true, inter: false})\n    }]\n}, 22974);\ngetType({k: 5, props: [{n: \"foo\", t: getType({n: \"string\", k: 2})}, {n: \"bar\", t: getType({n: \"string\", k: 2})}]}, 22969);\ngetType({\n    n: \"SomeType\",\n    fn: \"..\\\\logger.ts:SomeType\",\n    props: [{n: \"array\", t: getType({k: 4, n: \"Array\", args: [getType(22969)]})}],\n    ctors: [{params: []}],\n    k: 1,\n    ctor: () =\u003e SomeType\n}, 22965);\ngetType({\n    n: \"Foo\",\n    fn: \"..\\\\logger.ts:Foo\",\n    props: [{n: \"prop\", t: getType({n: \"number\", k: 2})}],\n    ctors: [{params: [{n: \"prop\", t: getType({n: \"number\", k: 2})}]}],\n    k: 1,\n    ctor: () =\u003e Foo\n}, 22976);\n```\n\n## Synopsis\n\n```typescript\n/**\n * Object representing TypeScript type in memory\n */\nexport declare class Type {\n    static readonly Object: Type;\n    static readonly Unknown: Type;\n    static readonly Any: Type;\n    static readonly Void: Type;\n    static readonly String: Type;\n    static readonly Number: Type;\n    static readonly BigInt: Type;\n    static readonly Boolean: Type;\n    static readonly Date: Type;\n    static readonly Null: Type;\n    static readonly Undefined: Type;\n    static readonly Never: Type;\n    /**\n     * Returns information about conditional type.\n     */\n    get condition(): ConditionalType | undefined;\n    /**\n     * Returns information about indexed access type.\n     */\n    get indexedAccessType(): IndexedAccessType | undefined;\n    /**\n     * List of underlying types in case Type is union or intersection\n     */\n    get types(): ReadonlyArray\u003cType\u003e;\n    /**\n     * Get meta for the module of the defined constructor\n     * This data is not set when the config mode is set to \"universal\"\n     */\n    get constructorDescription(): ConstructorImport | undefined;\n    /**\n     * Get definition of a generic type.\n     */\n    get genericTypeDefinition(): Type | undefined;\n    /**\n     * Base type\n     * @description Base type from which this type extends from or undefined if type is Object.\n     */\n    get baseType(): Type | undefined;\n    /**\n     * Interface which this type implements\n     */\n    get interface(): Type | undefined;\n    /**\n     * Get type full-name\n     * @description Contains file path base to project root\n     */\n    get fullName(): string;\n    /**\n     * Get type name\n     */\n    get name(): string;\n    /**\n     * Get kind of type\n     */\n    get kind(): TypeKind;\n    /**\n     * Underlying value in case of literal type\n     */\n    get literalValue(): any;\n    /**\n     * Generic type constrains\n     */\n    get genericTypeConstraint(): Type | undefined;\n    /**\n     * Generic type default value\n     */\n    get genericTypeDefault(): any;\n    /**\n     * Search the type store for a specific type\n     *\n     * Runs the provided filter callback on each type. If your filter returns true, it returns this type.\n     *\n     * @param {(type: Type) =\u003e boolean} filter\n     * @returns {Type | undefined}\n     */\n    static find(filter: (type: Type) =\u003e boolean): Type | undefined;\n    /**\n     * Returns all Types contained in metadata.\n     * This method is quite useless with reflection.metadata.type = \"inline\"; Use \"typelib\" type.\n     */\n    static getTypes(): Type[];\n    static get store(): MetadataStore;\n    /**\n     * Returns true if types are equals\n     * @param type\n     */\n    is(type: Type): boolean;\n    /**\n     * Returns a value indicating whether the Type is container for unified Types or not\n     */\n    isUnion(): boolean;\n    /**\n     * Returns a value indicating whether the Type is container for intersecting Types or not\n     */\n    isIntersection(): boolean;\n    /**\n     * Returns true whether current Type is a class with any constructor.\n     */\n    isInstantiable(): boolean;\n    /**\n     * Returns a value indicating whether the Type is a class or not\n     */\n    isClass(): boolean;\n    /**\n     * Returns a value indicating whether the Type is a interface or not\n     */\n    isInterface(): boolean;\n    /**\n     * Returns a value indicating whether the Type is an literal or not\n     */\n    isLiteral(): boolean;\n    /**\n     * Returns a value indicating whether the Type is an object literal or not\n     */\n    isObjectLiteral(): boolean;\n    /**\n     * Returns true if type is union or intersection of types\n     */\n    isUnionOrIntersection(): boolean;\n    /**\n     * Check if this is a native type (\"string\", \"number\", \"boolean\", \"Array\" etc.)\n     */\n    isNative(): boolean;\n    /**\n     * Check whether the type is generic.\n     */\n    isGenericType(): boolean;\n    /**\n     * Check if this is a primitive type (\"string\", \"number\", \"boolean\" etc.)\n     */\n    isPrimitive(): boolean;\n    /**\n     * Check if this type is a string\n     */\n    isString(): boolean;\n    /**\n     * Check if this type is a number\n     */\n    isNumber(): boolean;\n    /**\n     * Check if this type is a symbol\n     */\n    isSymbol(): boolean;\n    /**\n     * Check if this type is a boolean\n     */\n    isBoolean(): boolean;\n    /**\n     * Check if this type is an array\n     */\n    isArray(): boolean;\n    /**\n     * Check if this type is a promise\n     */\n    isPromise(): boolean;\n    /**\n     * Check if this type is a Tuple\n     */\n    isTuple(): boolean;\n    /**\n     * Check if this type is an any\n     */\n    isAny(): boolean;\n    /**\n     * Check if this type is a \"unknown\".\n     */\n    isUnknown(): boolean;\n    /**\n     * Check if this type is a \"undefined\" literal.\n     */\n    isUndefined(): boolean;\n    /**\n     * Check if this type is a \"null\" literal.\n     */\n    isNull(): boolean;\n    /**\n     * Check if this type is a \"true\" literal.\n     */\n    isTrue(): boolean;\n    /**\n     * Check if this type is a \"false\" literal.\n     */\n    isFalse(): boolean;\n    /**\n     *\n     * @return {boolean}\n     */\n    isObjectLike(): boolean;\n    /**\n     * Determines whether the object represented by the current Type is an Enum.\n     * @return {boolean}\n     */\n    isEnum(): boolean;\n    /**\n     * Returns information about the enumerable elements.\n     */\n    getEnum(): EnumInfo | undefined;\n    /**\n     * Constructor function in case Type is class\n     */\n    getCtor(): Promise\u003c{\n        new (...args: any[]): any;\n    } | undefined\u003e;\n    /**\n     * Returns array of function call signatures.\n     */\n    getSignatures(): ReadonlyArray\u003cFunctionInfo\u003e;\n    /**\n     * Returns array of type parameters.\n     */\n    getTypeParameters(): ReadonlyArray\u003cType\u003e;\n    /**\n     * Returns type arguments in case of generic type\n     */\n    getTypeArguments(): ReadonlyArray\u003cType\u003e;\n    /**\n     * Returns constructor description when Type is a class\n     */\n    getConstructors(): ReadonlyArray\u003cConstructorInfo\u003e | undefined;\n    /**\n     * Returns array of properties\n     */\n    getProperties(): ReadonlyArray\u003cPropertyInfo\u003e;\n    /**\n     * Returns array of indexes\n     */\n    getIndexes(): ReadonlyArray\u003cIndexInfo\u003e;\n    /**\n     * Returns array of methods\n     */\n    getMethods(): ReadonlyArray\u003cMethodInfo\u003e;\n    /**\n     * Returns array of decorators\n     */\n    getDecorators(): ReadonlyArray\u003cDecorator\u003e;\n    /**\n     * Returns object with all methods and properties from current Type and all methods and properties inherited from base types and interfaces to this Type.\n     * @return {{properties: {[p: string]: PropertyInfo}, methods: {[p: string]: MethodInfo}}}\n     */\n    flattenInheritedMembers(): {\n        properties: {\n            [propertyName: string]: PropertyInfo;\n        };\n        methods: {\n            [methodName: string]: MethodInfo;\n        };\n    };\n    /**\n     * Determines whether the class represented by the current Type derives from the class represented by the specified Type\n     * @param {Type} classType\n     */\n    isSubclassOf(classType: Type): boolean;\n    /**\n     * Determines whether the current Type derives from the specified Type\n     * @param {Type} targetType\n     */\n    isDerivedFrom(targetType: Type): boolean;\n    /**\n     * Determines whether the Object represented by the current Type is structurally compatible and assignable to the Object represented by the specified Type\n     * @param {Type} target\n     * @return {boolean}\n     * @private\n     */\n    isStructurallyAssignableTo(target: Type): boolean;\n    /**\n     * Determines whether an instance of the current Type can be assigned to an instance of the specified Type.\n     * @description This is fulfilled by derived types or compatible types.\n     * @param target\n     */\n    isAssignableTo(target: Type): boolean;\n    /**\n     * Returns string representation of the type.\n     */\n    toString(): string;\n}\n\n/**\n * Kind of type\n */\nexport declare enum TypeKind\n{\n    /**\n     * Interface\n     */\n    Interface = 0,\n    /**\n     * Class\n     */\n    Class = 1,\n    /**\n     * Native JavaScript/TypeScript type\n     */\n    Native = 2,\n    /**\n     * Container for other types in case of types union or intersection\n     */\n    Container = 3,\n    /**\n     * Type reference created during type checking\n     * @description Usually Array\u003c...\u003e, ReadOnly\u003c...\u003e etc.\n     */\n    TransientTypeReference = 4,\n    /**\n     * Some specific object\n     * @description Eg. \"{ foo: string, bar: boolean }\"\n     */\n    Object = 5,\n    /**\n     * Some subtype of string, number, boolean\n     * @example \u003ccaption\u003etype Foo = \"hello world\" | \"hello\"\u003c/caption\u003e\n     * String \"hello world\" is literal type and it is subtype of string.\n     *\n     * \u003ccaption\u003etype TheOnlyTrue = true;\u003c/caption\u003e\n     * Same as true is literal type and it is subtype of boolean.\n     */\n    LiteralType = 6,\n    /**\n     * Fixed lenght arrays literals\n     * @example \u003ccaption\u003etype Coords = [x: number, y: number, z: number];\u003c/caption\u003e\n     */\n    Tuple = 7,\n    /**\n     * Generic parameter type\n     * @description Represent generic type parameter of generic types. Eg. it is TType of class Animal\u003cTType\u003e {}.\n     */\n    TypeParameter = 8,\n    /**\n     * Conditional type\n     */\n    ConditionalType = 9,\n    /**\n     * Indexed access type\n     * @description Eg. get\u003cK extends keyof TypeKind\u003e(key: K): ==\u003e\u003e TypeKind[K] \u003c\u003c==\n     */\n    IndexedAccess = 10,\n    /**\n     * Typescript \"module\"\n     * @description Value module or namespace module\n     */\n    Module = 11,\n    /**\n     * Specific method used as type\n     */\n    Method = 12,\n    /**\n     * Enum\n     */\n    Enum = 13\n}\n\nexport declare enum Accessor\n{\n    None = 0,\n    Getter = 1,\n    Setter = 2\n}\n\nexport declare enum AccessModifier\n{\n    Private = 0,\n    Protected = 1,\n    Public = 2\n}\n\nexport interface ConditionalType\n{\n    /**\n     * Extends type\n     */\n    extends: Type;\n    /**\n     * True type\n     */\n    trueType: Type;\n    /**\n     * False type\n     */\n    falseType: Type;\n}\n\n/**\n * Property description\n */\nexport class Property\n{\n    /**\n     * Property name\n     */\n    readonly name: string;\n    /**\n     * Property type\n     */\n    readonly type: Type;\n    /**\n     * Optional property\n     */\n    readonly optional: boolean;\n    /**\n     * Access modifier\n     */\n    readonly accessModifier: AccessModifier;\n    /**\n     * Accessor\n     */\n    readonly accessor: Accessor;\n    /**\n     * Readonly\n     */\n    readonly readonly: boolean;\n    /**\n     * Returns array of decorators\n     */\n    getDecorators(): ReadonlyArray\u003cDecorator\u003e;\n}\n\n/**\n * Decoration description\n */\nexport class Decorator {\n    /**\n     * Decorator name\n     */\n    name: string;\n    /**\n     * Decorator full name\n     */\n    fullName?: string;\n    /**\n     * List of literal arguments\n     */\n    getArguments(): Array\u003cany\u003e;\n}\n\n/**\n * Method parameter description\n */\nexport interface MethodParameter\n{\n    /**\n     * Parameter name\n     */\n    name: string;\n    /**\n     * Parameter type\n     */\n    type: Type;\n    /**\n     * Parameter is optional\n     */\n    optional: boolean;\n}\n\nexport declare class MethodBase\n{\n    /**\n     * Parameters of this method\n     */\n    getParameters(): ReadonlyArray\u003cMethodParameter\u003e;\n}\n\n/**\n * Method details\n */\nexport declare class Method extends MethodBase\n{\n    /**\n     * Name of this method\n     */\n    get name(): string;\n\n    /**\n     * Return type of this method\n     */\n    get returnType(): Type;\n\n    /**\n     * Method is optional\n     */\n    get optional(): boolean;\n\n    /**\n     * Access modifier\n     */\n    get accessModifier(): AccessModifier;\n\n    /**\n     * Returns list of generic type parameter.\n     * @return {Array\u003cType\u003e}\n     */\n    getTypeParameters(): ReadonlyArray\u003cType\u003e;\n\n    /**\n     * Returns array of decorators\n     */\n    getDecorators(): ReadonlyArray\u003cDecorator\u003e;\n}\n\n/**\n * Constructor details\n */\nexport declare class Constructor extends MethodBase\n{\n}\n\nexport interface EnumInfo {\n    /**\n     * Get enum enumerators/items (keys).\n     */\n    getEnumerators(): string[];\n    /**\n     * Get values.\n     */\n    getValues(): any[];\n    /**\n     * Get enum entries (key:value pairs).\n     */\n    getEntries(): Array\u003creadonly [enumeratorName: string, value: any]\u003e;\n}\n```\n\n## Contributors ✨\n\nThanks go to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://bitbucket.org/HookCZ/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/2551259?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRoman Jámbor\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=Hookyns\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#maintenance-Hookyns\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=Hookyns\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/pulls?q=is%3Apr+reviewed-by%3AHookyns\" title=\"Reviewed Pull Requests\"\u003e👀\u003c/a\u003e \u003ca href=\"#example-Hookyns\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"#ideas-Hookyns\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#infra-Hookyns\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"#question-Hookyns\" title=\"Answering Questions\"\u003e💬\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=Hookyns\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/iDevelopThings\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4105581?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSam Parton\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=iDevelopThings\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3AiDevelopThings\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"#ideas-iDevelopThings\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://filmos.net/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/78136833?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eFilmos\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3AFilmos\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://dunglas.fr/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/57224?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKévin Dunglas\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-dunglas\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/usaccounts\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/12177064?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eusaccounts\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Ausaccounts\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/caiodallecio\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/20131875?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ecaiodallecio\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-caiodallecio\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/hugebdu\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1109601?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDaniel Shmuglin\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Ahugebdu\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"#ideas-hugebdu\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/avin-kavish\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/48435155?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAvin\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Aavin-kavish\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=avin-kavish\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://joeferner.github.io/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/808857?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJoe Ferner\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/commits?author=joeferner\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://dhkatz.dev\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/8341611?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDavid Katz\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Adhkatz\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://experimental-learning.com/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/58147075?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJamesb \u0026#124; Experimental Learning\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Abjsi\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.linkedin.com/in/carloszimmerle/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4553211?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCarlos Zimmerle\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-carloszimm\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/Hookyns/tst-reflect/issues?q=author%3Acarloszimm\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://allcontributors.org) specification.\nContributions of any kind are welcome!\n\n## Motivation\n\nI'm developing this Reflection system for [own Dependency Injection system](https://github.com/Hookyns/NetLeaf/tree/main/libraries/extensions-dependency-injection-typed), to allow registering and resolving based on types. Something like:\n\n```\nserviceCollection.addTransient\u003cILog, Log\u003e();\n...\nserviceProvider.getService\u003cILog\u003e();\n```\n\nWhere `getService()` takes care about constructor's parameters, based on their types, and resolve everything.\n\n## License\nThis project is licensed under the [MIT license](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhookyns%2Ftst-reflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhookyns%2Ftst-reflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhookyns%2Ftst-reflect/lists"}