{"id":20177219,"url":"https://github.com/kitajs/ts-writer","last_synced_at":"2025-04-10T04:25:19.533Z","repository":{"id":205018584,"uuid":"713211548","full_name":"kitajs/ts-writer","owner":"kitajs","description":"Ts Writer is a simple and lightweight library to generate js and dts files using template strings.","archived":false,"fork":false,"pushed_at":"2024-05-20T18:59:42.000Z","size":179,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-24T05:43:46.294Z","etag":null,"topics":["code","dts","generator","js","kita","source","strings","template","ts","writer"],"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/kitajs.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kitajs","arthurfiorette"]}},"created_at":"2023-11-02T03:55:55.000Z","updated_at":"2023-11-06T13:12:31.000Z","dependencies_parsed_at":"2024-05-06T19:47:48.910Z","dependency_job_id":"8e9d225c-e74d-461a-8625-c13d77f1e5e4","html_url":"https://github.com/kitajs/ts-writer","commit_stats":null,"previous_names":["kitajs/ts-writer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitajs%2Fts-writer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitajs%2Fts-writer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitajs%2Fts-writer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitajs%2Fts-writer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitajs","download_url":"https://codeload.github.com/kitajs/ts-writer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248156204,"owners_count":21056796,"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":["code","dts","generator","js","kita","source","strings","template","ts","writer"],"created_at":"2024-11-14T02:14:30.518Z","updated_at":"2025-04-10T04:25:19.512Z","avatar_url":"https://github.com/kitajs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kitajs","https://github.com/sponsors/arthurfiorette"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003cb\u003eUsing this package?\u003c/b\u003e Please consider \u003ca href=\"https://github.com/sponsors/arthurfiorette\" target=\"_blank\"\u003edonating\u003c/a\u003e to support my open source work ❤️\n  \u003cbr /\u003e\n  \u003csup\u003e\n   Help ts-writer grow! Star and share this amazing repository with your friends and co-workers!\n  \u003c/sup\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n\u003cp align=\"center\" \u003e\n  \u003ca href=\"https://kita.js.org\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg src=\"https://kita.js.org/logo.png\" width=\"180\" alt=\"Kita JS logo\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca title=\"MIT license\" target=\"_blank\" href=\"https://github.com/kitajs/ts-writer/blob/master/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/kitajs/ts-writer\"\u003e\u003c/a\u003e\n  \u003ca title=\"Codecov\" target=\"_blank\" href=\"https://app.codecov.io/gh/kitajs/ts-writer\"\u003e\u003cimg alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/kitajs/ts-writer?token=ML0KGCU0VM\"\u003e\u003c/a\u003e\n  \u003ca title=\"NPM Package\" target=\"_blank\" href=\"https://www.npmjs.com/package/ts-writer\"\u003e\u003cimg alt=\"Downloads\" src=\"https://img.shields.io/npm/dw/ts-writer?style=flat\"\u003e\u003c/a\u003e\n  \u003ca title=\"Bundle size\" target=\"_blank\" href=\"https://bundlephobia.com/package/ts-writer@latest\"\u003e\u003cimg alt=\"Bundlephobia\" src=\"https://img.shields.io/bundlephobia/minzip/ts-writer/latest?style=flat\"\u003e\u003c/a\u003e\n  \u003ca title=\"Last Commit\" target=\"_blank\" href=\"https://github.com/kitajs/ts-writer/commits/master\"\u003e\u003cimg alt=\"Last commit\" src=\"https://img.shields.io/github/last-commit/kitajs/ts-writer\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/kitajs/ts-writer/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/kitajs/ts-writer?logo=github\u0026label=Stars\" alt=\"Stars\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n\u003ch1\u003e🧾 Ts Writer\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  Ts Writer is a simple and lightweight library to generate js and dts files using template strings.\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [Installing](#installing)\n- [Getting Started](#getting-started)\n- [Generating code](#generating-code)\n- [Syntax Highlighting](#syntax-highlighting)\n- [License](#license)\n\n\u003cbr /\u003e\n\n## Installing\n\n```sh\nnpm install ts-writer # or yarn add ts-writer\n```\n\n```js\nconst { TsWriter } = require('ts-writer');\nimport { TsWriter } from 'ts-writer';\n```\n\n```js\nconst { TsWriter } = window.tsWriter;\n```\n\n```js\nimport { TsWriter } from 'https://cdn.skypack.dev/ts-writer@latest';\n```\n\n\u003cbr /\u003e\n\n## Getting Started\n\nTs Writer is a simple and lightweight library to generate js and dts files using template\nstrings. It is very simple to use and has a very small footprint, perfect designed to be\nused in CLIs and Code generation tools.\n\nThere's numerous reasons why code generation increases performance even as javascript is a\nJIC interpreted language, this library helps you to generate the code you need at runtime\n**in typescript** without having to handle transpiling, multiple files, etc.\n\n## Generating code\n\nThe syntax is pretty simple:\n\n```ts\nfunction generate() {\n  const { source, types } = ts`${'filename'}\n\n  // Any text here will be put inside the source.content variable above. Under\n  // the filename.js file.\n\n  // It will auto remove indentation if you call ts inside a indentation block.\n  // like this function.\n\n  exports = 'Hello World';\n  exports.__esModule = true;\n\n  ${ts.types}\n\n  // If you want to also generate a filename.d.ts file, you can use the ts.types\n  // variable above. Everything after it will be put inside the types variable above.\n  // (filename.d.ts)\n\n  export default 'Hello World';\n  `;\n\n  // Source result\n  source = {\n    filename: 'filename.js',\n    content:\n      '// Any text here will be put inside the source.content variable above. Under\\n' +\n      '// the filename.js file.\\n' +\n      '\\n' +\n      '// It will auto remove indentation if you call ts inside a indentation block.\\n' +\n      '// like this function.\\n' +\n      '\\n' +\n      \"exports = 'Hello World';\\n\" +\n      'exports.__esModule = true;'\n  };\n\n  // Types result\n  types = {\n    filename: 'filename.d.ts',\n    content:\n      '// If you want to also generate a filename.d.ts file, you can use the ts.types\\n' +\n      '// variable above. Everything after it will be put inside the types variable above.\\n' +\n      '// (filename.d.ts)\\n' +\n      '\\n' +\n      \"export default 'Hello World';\"\n  };\n}\n```\n\n## Syntax Highlighting\n\nIf you are using VSCode, the\n[`bierner.comment-tagged-templates`](https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates)\nextension will highlight the template strings if you put `/*ts*/` comment between the `ts`\nand its backticks:\n\n![example](assets/syntax-highlighting.png)\n\n## License\n\nLicensed under the **MIT**. See [`LICENSE`](LICENSE) for more informations.\n\n\u003cbr /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitajs%2Fts-writer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitajs%2Fts-writer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitajs%2Fts-writer/lists"}