{"id":19475474,"url":"https://github.com/artdecocode/typework","last_synced_at":"2025-06-30T10:35:36.367Z","repository":{"id":57384061,"uuid":"192996312","full_name":"artdecocode/typework","owner":"artdecocode","description":"Manage And Vendor JSDoc Types.","archived":false,"fork":false,"pushed_at":"2019-07-21T12:57:11.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T14:51:26.314Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.artd.eco","language":"JavaScript","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/artdecocode.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-20T22:49:40.000Z","updated_at":"2019-12-20T05:18:13.000Z","dependencies_parsed_at":"2022-09-14T17:43:00.041Z","dependency_job_id":null,"html_url":"https://github.com/artdecocode/typework","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/artdecocode/typework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Ftypework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Ftypework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Ftypework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Ftypework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artdecocode","download_url":"https://codeload.github.com/artdecocode/typework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Ftypework/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261631283,"owners_count":23187233,"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":[],"created_at":"2024-11-10T19:33:04.362Z","updated_at":"2025-06-30T10:35:36.288Z","avatar_url":"https://github.com/artdecocode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typework\n\n[![npm version](https://badge.fury.io/js/typework.svg)](https://npmjs.org/package/typework)\n\n_Typework_ is used to Manage And Vendor JSDoc Types. With the special `/* typework */` keyword, JSDoc type declarations can be moved across JS files, and imported files in types (`import('../types/context')`) will be copied across to the target project.\n\n```sh\nyarn add typework\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [CLI](#cli)\n- [Copyright](#copyright)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\"/.documentary/section-breaks/0.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## CLI\n\nThe package works via a CLI by passing the configuration file to it.\n\n```\ntypework example/config.json\n```\n\nThe config must include 3 properties:\n\n```json\n{\n  \"entry\": \"@typedefs/goa\",\n  \"js\": \"compile/index.js\",\n  \"destination\": \"types\"\n}\n```\n\n- \u003ckbd\u003e🔖 entry\u003c/kbd\u003e This is where the types are coming form. This can be a separate package, e.g., `@typedefs/goa`\n- \u003ckbd\u003e🎯 js\u003c/kbd\u003e The project source code into where to place the original types into.\n- \u003ckbd\u003e📂 destination\u003c/kbd\u003e Whenever the types import other files with `import('../types/')`, the target files will be copied to this folder.\n\nUpon run, the types' JSDoc declarations are copied from the entry into the source _JS_ file, so that they become a native part of the project. All other files found under relative import paths, will be placed into the _Destination_ folder.\n\nThe example below demonstrates, how types written for the [_Goa_](https://github.com/idiocc/goa/blob/master/types) package and published as [`@typedefs/goa`](https://npmjs.com/package/@typedefs/goa), were imported into the [_Goa/Koa_](https://github.com/idiocc/koa) project, so that they can be distributed without having to install `@typedefs/goa` from NPM as a production dependency. This is a strategy for distribution of JSDoc types.\n\n\u003ctable\u003e\n\u003ctr\u003e\u003ctd\u003e\n \u003ca href=\"https://github.com/idiocc/goa/blob/master/types/index.js\"\u003eentry.js\u003c/a\u003e\u003c/td\u003e\n\n\u003ctd\u003e\u003cem\u003eTypework\u003c/em\u003e will read the entry files, to detect the \u003ccode\u003e/* typework */\u003c/code\u003e market which indicates a single block of types which can be managed by the binary (only types within this block will be worked on).\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd colspan=\"2\"\u003e\n\n```js\nexport {}\n\n/* typework */\n/**\n * @typedef {import('./vendor/cookies').Keygrip} Keygrip\n * @typedef {import('./typedefs/application').Middleware} Middleware\n * @typedef {import('./typedefs/application').Application} Application\n * @typedef {import('./typedefs/context').KoaContext} Context\n * @typedef {import('./typedefs/request').Request} Request\n * @typedef {import('./typedefs/request').ContextDelegatedRequest} ContextDelegatedRequest\n * @typedef {import('./typedefs/response').Response} Response\n * @typedef {import('./typedefs/response').ContextDelegatedResponse} ContextDelegatedResponse\n */\n```\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\n \u003ca href=\"example/index2.js\"\u003eindex2.js\u003c/a\u003e\n\u003c/td\u003e\u003ctd\u003eThe JS file where the types need to be placed, will also contain the \u003ccode\u003e/* typework */\u003c/code\u003e marker, but only a single one. It should be at the end and allow for 1 extra line at the end (a file cannot finish with \u003ccode\u003e*/\u003c/code\u003e, only \u003ccode\u003e*/\\n\u003c/code\u003e).\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd colspan=\"2\"\u003e\n\n```js\nconst _Koa = require('./koa')\n\nclass Koa extends _Koa {\n  /**\n   * Initialize a new `Application`.\n   */\n  constructor() {\n    super()\n  }\n}\n\nmodule.exports = Koa\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ckbd\u003eShow Typework\u003c/kbd\u003e\u003c/summary\u003e\n\n```js\n/* typework */\n/**\n * @typedef {import('types/vendor/cookies').Keygrip} Keygrip\n * @typedef {import('types/typedefs/application').Middleware} Middleware\n * @typedef {import('types/typedefs/application').Application} Application\n * @typedef {import('types/typedefs/context').KoaContext} Context\n * @typedef {import('types/typedefs/request').Request} Request\n * @typedef {import('types/typedefs/request').ContextDelegatedRequest} ContextDelegatedRequest\n * @typedef {import('types/typedefs/response').Response} Response\n * @typedef {import('types/typedefs/response').ContextDelegatedResponse} ContextDelegatedResponse\n */\n```\n\u003c/details\u003e\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\n \u003ca href=\"example/types\"\u003etypes\u003c/a\u003e\n\u003c/td\u003e\u003ctd\u003eThe purpose of \u003cem\u003eTypework\u003c/em\u003e is to vendor JSDoc across packages easily, so that the IDE documentation can be shown without relying on additional infrastructure like \u003cem\u003eTypings\u003c/em\u003e. One of downside of current JSDoc is the lack of import statements, therefore \u003cem\u003eTypework\u003c/em\u003e is meant to work in environments which support \u003ccode\u003eimport\u003c/code\u003e.\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd colspan=\"2\"\u003e\n\n```m\nexample/types\n├── typedefs\n│   ├── application.js\n│   ├── context.js\n│   ├── request.js\n│   └── response.js\n└── vendor\n    ├── accepts.js\n    └── cookies.js\n```\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\"/.documentary/section-breaks/1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Copyright\n\n(c) [Art Deco][1] 2019\n\n[1]: https://artd.eco\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\"/.documentary/section-breaks/-1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartdecocode%2Ftypework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartdecocode%2Ftypework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartdecocode%2Ftypework/lists"}