{"id":18609645,"url":"https://github.com/unlight/typescript-transform-unspec","last_synced_at":"2025-09-10T16:46:13.490Z","repository":{"id":57383965,"uuid":"191311581","full_name":"unlight/typescript-transform-unspec","owner":"unlight","description":"Typescript transform plugin removes spec definition from source file","archived":false,"fork":false,"pushed_at":"2019-06-14T18:21:33.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-27T04:17:12.093Z","etag":null,"topics":["typescript-compiler","typescript-plugin","typescript-transform-plugin","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/unlight.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}},"created_at":"2019-06-11T06:52:44.000Z","updated_at":"2019-10-31T14:38:58.000Z","dependencies_parsed_at":"2022-09-14T17:53:24.175Z","dependency_job_id":null,"html_url":"https://github.com/unlight/typescript-transform-unspec","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Ftypescript-transform-unspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Ftypescript-transform-unspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Ftypescript-transform-unspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Ftypescript-transform-unspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unlight","download_url":"https://codeload.github.com/unlight/typescript-transform-unspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239400596,"owners_count":19632049,"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":["typescript-compiler","typescript-plugin","typescript-transform-plugin","typescript-transformer"],"created_at":"2024-11-07T03:06:45.452Z","updated_at":"2025-02-18T03:14:58.307Z","avatar_url":"https://github.com/unlight.png","language":"TypeScript","readme":"# typescript-transform-unspec\nTypescript transform plugin removes spec definition from source file.  \nInspired by [unassert](https://github.com/unassert-js/unassert).\n\n## Motivation\nImagine we have `function.ts` with single function. Usually we create `function.spec.ts` with tests.\nBut what if we can keep tests in same file, and remove spec defenition for production.\n\n## Example\n\n### Before\n```ts\nexport function hello(greet = 'world') {\n    return `hello ${greet}`;\n}\n\nit('hello world test', () =\u003e {\n    expect(hello()).toBe('hello world');\n});\n```\n\n### After (`it` removed)\n```js\nfunction hello(greet) {\n    if (greet === void 0) { greet = 'world'; }\n    return \"hello \" + greet;\n}\n````\n\n### Pros and Cons\n\\+ All in one file  \n\\- Collecting coverage can be tricky  \n\n## Installation\n```sh\nnpm install --save-dev typescript-transform-unspec\n```\n\n## Usage\n\n#### webpack (with ts-loader or awesome-typescript-loader)\n```js\n// webpack.config.js\nconst unspecTransformer = require('typescript-transform-unspec');\n\nrules: [\n  {\n    test: /\\.tsx?$/,\n    loader: 'ts-loader', // or 'awesome-typescript-loader'\n    options: {\n      getCustomTransformers: program =\u003e ({\n          before: [\n              unspecTransformer(program),\n          ]\n      })\n    }\n  },\n]\n```\n\n#### TTypescript\n```json\n// tsconfig.json\n{\n    \"compilerOptions\": {\n        \"plugins\": [\n            { \"transform\": \"typescript-transform-unspec\" },\n        ]\n    },\n}\n```\n\n#### Rollup (with rollup-plugin-typescript2)\n```js\n// rollup.config.js\nimport typescript from 'rollup-plugin-typescript2';\nimport unspecTransformer from 'typescript-transform-unspec';\n\nplugins: [\n  typescript({ \n    transformers: [\n        service =\u003e ({ \n            before: [unspecTransformer(service.getProgram())],\n            after: [],\n        }),\n    ],\n  }),\n]\n```\n\n## Resources\n- https://dev.doctorevidence.com/how-to-write-a-typescript-transform-plugin-fc5308fdd943\n- https://github.com/Saviio/ts-sfc-plugin\n- https://github.com/LeDDGroup/typescript-transform-jsx\n- https://github.com/Saviio/ts-react-pure-class-plugin\n- https://github.com/uittorio/ts-auto-mock\n- https://github.com/geocine/typescript-transform\n- https://github.com/cevek/ttypescript\n- https://github.com/rimeto/ts-optchain\n- https://github.com/woutervh-/typescript-is\n- https://github.com/kimamula/ts-transformer-keys\n- https://github.com/kimamula/ts-transformer-enumerat\n- https://github.com/firede/ts-transform-graphql-tag\n- https://github.com/longlho/ts-transform-img\n- https://github.com/longlho/ts-transform-css-modules\n- https://github.com/longlho/ts-transform-react-intl\n- https://github.com/dsherret/ts-nameof\n- https://github.com/LeDDGroup/typescript-transform-jsx\n- https://github.com/LeDDGroup/typescript-transform-paths\n- https://github.com/LeDDGroup/typescript-transform-macros\n- https://github.com/timocov/ts-transformer-minify-privates\n- https://github.com/cevek/ttypescript/tree/master/packages/ttypescript-examples/src\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Ftypescript-transform-unspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funlight%2Ftypescript-transform-unspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Ftypescript-transform-unspec/lists"}