{"id":13847345,"url":"https://github.com/goloveychuk/tsruntime","last_synced_at":"2025-09-13T06:41:38.201Z","repository":{"id":55517150,"uuid":"89846215","full_name":"goloveychuk/tsruntime","owner":"goloveychuk","description":"typescript: emitting types info for using in runtime (reflection)","archived":false,"fork":false,"pushed_at":"2024-01-02T15:16:02.000Z","size":283,"stargazers_count":44,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-30T15:28:20.550Z","etag":null,"topics":["reflect","runtime","typescript"],"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/goloveychuk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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}},"created_at":"2017-04-30T11:15:58.000Z","updated_at":"2024-11-01T16:39:35.000Z","dependencies_parsed_at":"2024-01-15T20:49:40.418Z","dependency_job_id":"dd11ea91-53ed-4b71-9807-c5945e56d704","html_url":"https://github.com/goloveychuk/tsruntime","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/goloveychuk/tsruntime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goloveychuk%2Ftsruntime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goloveychuk%2Ftsruntime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goloveychuk%2Ftsruntime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goloveychuk%2Ftsruntime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goloveychuk","download_url":"https://codeload.github.com/goloveychuk/tsruntime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goloveychuk%2Ftsruntime/sbom","scorecard":{"id":434928,"data":{"date":"2025-08-11","repo":{"name":"github.com/goloveychuk/tsruntime","commit":"db886578a63d79d7415f76350f89e0f38628cf99"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Code-Review","score":3,"reason":"Found 4/11 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/node.js.yml:1","Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/goloveychuk/tsruntime/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/goloveychuk/tsruntime/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/goloveychuk/tsruntime/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/goloveychuk/tsruntime/npm-publish.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":-1,"reason":"internal error: internal error: Client.Checks.ListCheckRunsForRef: error during graphqlHandler.setupCheckRuns: non-200 OK status code: 502 Bad Gateway body: \"\u003chtml\u003e\\r\\n\u003chead\u003e\u003ctitle\u003e502 Bad Gateway\u003c/title\u003e\u003c/head\u003e\\r\\n\u003cbody\u003e\\r\\n\u003ccenter\u003e\u003ch1\u003e502 Bad Gateway\u003c/h1\u003e\u003c/center\u003e\\r\\n\u003chr\u003e\u003ccenter\u003enginx\u003c/center\u003e\\r\\n\u003c/body\u003e\\r\\n\u003c/html\u003e\\r\\n\"","details":null,"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"65 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-jmqm-f2gx-4fjv","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T04:22:38.722Z","repository_id":55517150,"created_at":"2025-08-19T04:22:38.722Z","updated_at":"2025-08-19T04:22:38.722Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274929486,"owners_count":25375710,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["reflect","runtime","typescript"],"created_at":"2024-08-04T18:01:17.398Z","updated_at":"2025-09-13T06:41:38.150Z","avatar_url":"https://github.com/goloveychuk.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# tsruntime\n\n[![Build Status](https://travis-ci.org/goloveychuk/tsruntime.svg?branch=master)](https://travis-ci.org/goloveychuk/tsruntime)\n[![npm version](https://badge.fury.io/js/tsruntime.svg)](https://www.npmjs.com/package/tsruntime)\n\nTypescript custom transformer for emitting types for using in runtime (reflection).\n\n## Motivation\nSometimes you need types metadata in the runtime, e.g. to validate backend response or set `propTypes` from `interface Props{}` \n\n\n## Prerequisites\n- `typescript: =\u003e5.0.0`\n\n## Setup\n- install `tsruntime` and `ts-patch`\n- change `tsconfig.json`:\n```js\n{\n    \"compilerOptions\": {\n        \"experimentalDecorators\": true, // if you'll use decorators\n        \"plugins\": [\n            { \"transform\": \"tsruntime/dist/transform/transformer.js\", \"type\": \"program\" },\n        ],\n    }\n}\n```\n- run with `ts-patch` compiler:\n  - `ts-node --compiler=ts-patch/compiler src/index.ts`\n  - `tspc` \n  - change `compiler` in `awesome-typescript-loader` config\n  - etc\n### See [Example](./packages/example)\n\n### Warning: You cannot use `transpileOnly` compiling mode and `isolatedModules` (if you want reflect types from imported modules).\n\n## Usage:\n### Using `reflect` function\n\n```ts\nimport {reflect} from 'tsruntime';\n\ninterface StatsModel {\n    a?: number\n    b: string\n    c: Array\u003cstring\u003e\n    d: number | string | null\n}\n\nconst type = reflect\u003cStatsModel\u003e()\nconsole.log(type)\n\nconst type2 = reflect\u003cstring\u003e()\n```\nOn compiled code you'll have\n```js\nvar type = tsruntime_1.reflect({\n  kind: 15 /*Object*/,\n  name: \"StatsModel\",\n  properties: {\n    a: {\n      kind: 17 /*Union*/,\n      types: [{ kind: 12 /*Undefined*/ }, { kind: 3 /*Number*/ }]\n    },\n    b: { kind: 2 /*String*/ },\n    c: {\n      kind: 18 /*Reference*/,\n      type: Array,\n      arguments: [{ kind: 2 /*String*/ }]\n    },\n    d: {\n      kind: 17 /*Union*/,\n      types: [\n        { kind: 13 /*Null*/ },\n        { kind: 2 /*String*/ },\n        { kind: 3 /*Number*/ }\n      ]\n    }\n  }\n})();\n```\n### Using class decorators\n```ts\nimport {Reflective, getClassType} from 'tsruntime';\n\n@Reflective\nexport class StatsModel {\n    a?: number\n    b!: string\n    c!: Array\u003cstring\u003e\n    d!: number | string | null\n}\n\n@Reflective\nclass Foo extends Array\u003cstring\u003e {\n\n}\n\nconsole.log(getClassType(StatsModel))\nconsole.log(getClassType(Foo))\n```\nOn runtime you'll have\n```js\n// ...\nStatsModel = __decorate(\n    [\n      tsruntime_1.Reflective({\n        kind: 19 /*Class*/,\n        name: \"StatsModel\",\n        properties: {\n          a: {\n            kind: 17 /*Union*/,\n            types: [{ kind: 12 /*Undefined*/ }, { kind: 3 /*Number*/ }]\n          },\n          b: { kind: 2 /*String*/ },\n          c: {\n            kind: 18 /*Reference*/,\n            type: Array,\n            arguments: [{ kind: 2 /*String*/ }]\n          },\n          d: {\n            kind: 17 /*Union*/,\n            types: [\n              { kind: 13 /*Null*/ },\n              { kind: 2 /*String*/ },\n              { kind: 3 /*Number*/ }\n            ]\n          }\n        }\n      })\n    ],\n    StatsModel\n  );\n// ...\n```\n\n### Using types info\n```ts\nimport {Types, reflect} from 'tsruntime';\n\nconst isString = reflect\u003cstring\u003e().kind === Types.TypeKind.String\n```\n\n[Full runtime info available](./packages/tsruntime/src/runtime/publicTypes.ts)\n\n## Customization\nYou can customize both `reflect` and `Reflective` to do whatever you want\n\n```ts\n\nimport {createReflective, Types} from 'tsruntime';\n\nconst storage = {} as any\n\nfunction MyReflective (key: string) {\n    return createReflective(reflectedType =\u003e {\n        return (target: any) =\u003e {\n            storage[key] = reflectedType\n        }\n    })\n}\n\n// typeof MyReflective('realcls') is MarkReflective type.\n\n@MyReflective('realcls')\nclass Cls {\n    prop = 42\n}\n// in compiled code - @MyReflective('realcls')({kind: ...})\n\nconst clsType = storage['realcls']\n\n\nconst validateResp = createReflective(\n  reflectedType =\u003e \u003cT\u003e(resp: unknown) =\u003e { //should have \u003cT\u003e\n    if (reflectedType.kind === Types.TypeKind.String) {\n        return typeof resp === 'string'\n    }\n  }\n)\n\nconst isValid = validateResp\u003cstring\u003e('asd') \n// in compiled code - validateResp({kind: ...})('asd')\n\n```\n\n### How it works\n`createReflective` expects `reflectedType =\u003e T` to be passed as arg.\n\nIt returns `T` and marks it as reflectable (`type MarkReflective`).\n\nTransformer see that symbol have type `MarkReflective` and calls it with `reflectedType`. \n\nFor function it gets type from first generic argument (thats why you need `\u003cT\u003e`), for decorator - from class declaration, related to decorator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoloveychuk%2Ftsruntime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoloveychuk%2Ftsruntime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoloveychuk%2Ftsruntime/lists"}