{"id":13660882,"url":"https://github.com/artifact-project/tx-reflector","last_synced_at":"2025-04-24T23:30:56.665Z","repository":{"id":57383057,"uuid":"94994719","full_name":"artifact-project/tx-reflector","owner":"artifact-project","description":"TypeScript transformer for code generation.","archived":false,"fork":false,"pushed_at":"2017-11-28T10:07:45.000Z","size":19,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T17:30:16.617Z","etag":null,"topics":["artifact-project","interfaces","react","reflection","typescript-transformer"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artifact-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-21T10:57:05.000Z","updated_at":"2021-05-07T15:24:15.000Z","dependencies_parsed_at":"2022-09-11T04:51:54.562Z","dependency_job_id":null,"html_url":"https://github.com/artifact-project/tx-reflector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artifact-project%2Ftx-reflector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artifact-project%2Ftx-reflector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artifact-project%2Ftx-reflector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artifact-project%2Ftx-reflector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artifact-project","download_url":"https://codeload.github.com/artifact-project/tx-reflector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250727495,"owners_count":21477321,"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":["artifact-project","interfaces","react","reflection","typescript-transformer"],"created_at":"2024-08-02T05:01:26.937Z","updated_at":"2025-04-24T23:30:56.367Z","avatar_url":"https://github.com/artifact-project.png","language":"TypeScript","readme":"TX Reflector\n------------\nTypeScript transformer for code generation.\u003cbr/\u003e\nSee also [Interface-based instructions](https://github.com/artifact-project/ibi).\n\n\n### Install\n\n```\nnpm i --save-dev tx-reflector\n```\n\n\n### API\n\n - `getInterfaces(target: Function | object): string[]`\n - `getInterfaces\u003cT\u003e(target: T): string[]`\n - `getRawInterfaces\u003cT\u003e(target: T): Interface[]`\n - `getComponentInterfaces(XClass: Function): string[]`\n\n\n\n### Usage\n\n```ts\nimport {getInterfaces, getRawInterfaces, Interface} from 'tx-reflector';\n\nconst data: IData = {value: 'foo'};\nconst interfaces: string[] = getInterfaces(data); // OR getInterfaces\u003cIData\u003e(anything);\nconst rawInterfaces: Interface[] = getRawInterfaces(data);;\n\n// After compilation:\n//   var interfaces = [\"IData\", \"IAbstractData\"];\n//   var rawInterfaces = [\n//      {\n//         name: \"IData\",\n//         entries: [{name: \"value\", type: \"string\", optional: false}],\n//      }, {\n//         name: \"IAbstractData\",\n//         entries: [{name: \"source\", type: \"string\", optional: false}],\n//      },\n//   ];\n```\n\n\n### React and like\n\n```ts\nimport {getComponentInterfaces} from 'tx-reflector';\n\ninterface IBtnProps extends IComponent, IClickable {\n\tvalue: string;\n}\n\nclass Btn extends React.Component\u003cIBtnProps\u003e {\n}\n\n\nconst interfaces = getComponentInterfaces(Btn);\n\n// After compilation:\n//   var interfaces = [\"IBtnProps\", \"IComponent\", \"IClickable\"];\n```\n\n\n### Webpack\nUse [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader) or [ts-loader 2.3+](https://github.com/TypeStrong/ts-loader/).\n\n```js\n// webpack.config.js\nconst {default:txReflector} = require('tx-reflector/src/transformer/transformer');\n\nmodule.exports = {\n\t// ...\n\tmodule: {\n\t\t// ...\n\t\t{\n\t\t\ttest: /\\.tsx?$/,\n\t\t\tloader: 'awesome-typescript-loader', // or ts-loader\n\t\t\toptions: {\n\t\t\t\tgetCustomTransformers() {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tbefore: [txReflector],\n\t\t\t\t\t\tafter: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n\t// ...\n};\n```\n\n\n### Jest (only with TS 2.4+)\n\n```js\n// .jest/tsPreprocessor.js\nconst tsc = require('typescript');\nconst tsConfig = require('../tsconfig.json');\nconst {default:txReflector} = require('tx-reflector/src/transformer/transformer');\n\nmodule.exports = {\n\tprocess(src, path) {\n\t\tif (path.endsWith('.ts') || path.endsWith('.tsx')) {\n\t\t\tconst result = tsc.transpileModule(src, {\n\t\t\t\tcompilerOptions: tsConfig.compilerOptions,\n\t\t\t\tfileName: path,\n\t\t\t\ttransformers: {\n\t\t\t\t\tbefore: [txReflector],\n\t\t\t\t\tafter: [],\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn result.outputText;\n\t\t}\n\n\t\treturn src;\n\t},\n};\n```\n\n\n### Development\n\n - `npm i`\n - `npm test`, [code coverage](./coverage/lcov-report/index.html)\n\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartifact-project%2Ftx-reflector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartifact-project%2Ftx-reflector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartifact-project%2Ftx-reflector/lists"}