{"versions":{"0.8.3":{"name":"@unovue/detypes","version":"0.8.3","description":"Removes TypeScript type annotations but keeps the formatting","author":{"name":"Zernonia","email":"zernonia@gmail.com"},"license":"MIT","homepage":"https://github.com/unovue/detypes#readme","repository":{"type":"git","url":"git+https://github.com/unovue/detypes.git"},"bugs":{"url":"https://github.com/unovue/detypes/issues"},"keywords":["typescript","formatting","vue","sfc"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"main":"dist/index.js","bin":{"detypes":"detype.js"},"engines":{"node":">=18"},"dependencies":{"@babel/core":"^7.24.5","@babel/preset-typescript":"^7.24.1","@vue/compiler-dom":"^3.4.27","@vue/compiler-sfc":"^3.4.27","@vuedx/template-ast-types":"0.7.1","fast-glob":"^3.3.2","prettier":"^3.2.5","typescript":"^5.4.5"},"devDependencies":{"@antfu/eslint-config":"^2.17.0","@babel/traverse":"^7.24.5","@types/babel__core":"^7.20.5","@types/babel__traverse":"^7.20.5","@types/node":"18.15.11","bumpp":"^9.4.1","eslint":"^9.2.0","npm-run-all":"^4.1.5","rimraf":"^5.0.7","tsup":"^8.0.2","vitest":"^1.6.0"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest","typecheck":"tsc -p tsconfig.json --noEmit","lint":"eslint .","lint:fix":"eslint . --fix","release":"bumpp package.json"},"_id":"@unovue/detypes@0.8.3","types":"./dist/index.d.ts","_integrity":"sha512-C6ca7LY7o0VzOndwErGlxbDUehWdf1GiWIGhB40dgzrkhzY6XF/lt2j9gR9A9mHD/+gqQyBeh5DLHQQDzr369A==","_resolved":"/tmp/16eabdee4ee83b80e14783971d1c02c2/unovue-detypes-0.8.3.tgz","_from":"file:unovue-detypes-0.8.3.tgz","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-C6ca7LY7o0VzOndwErGlxbDUehWdf1GiWIGhB40dgzrkhzY6XF/lt2j9gR9A9mHD/+gqQyBeh5DLHQQDzr369A==","shasum":"aab7fac28a33048f3deb2dd7f5de44692d864992","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@unovue/detypes/-/detypes-0.8.3.tgz","fileCount":11,"unpackedSize":61032,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDicq0jofnHGkUoORRHaZ3RmS7+Bkx5b5ig2lK/uxZiZwIgTNMGnJCth6isS/+IBtHKDVhQE9KrCHMywozTc309XBg="}],"size":11063},"_npmUser":{"name":"anonymous","email":"zernonia@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"zernonia@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detypes_0.8.3_1728621277241_0.5188797862052676"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-11T04:34:37.473Z","publish_time":1728621277473,"_source_registry_name":"default","contributors":[]},"0.8.4":{"name":"@unovue/detypes","version":"0.8.4","description":"Removes TypeScript type annotations but keeps the formatting","author":{"name":"Zernonia","email":"zernonia@gmail.com"},"license":"MIT","homepage":"https://github.com/unovue/detypes#readme","repository":{"type":"git","url":"git+https://github.com/unovue/detypes.git"},"bugs":{"url":"https://github.com/unovue/detypes/issues"},"keywords":["typescript","formatting","vue","sfc"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"main":"dist/index.js","bin":{"detypes":"detype.js"},"engines":{"node":">=18"},"dependencies":{"@babel/core":"^7.24.5","@babel/preset-typescript":"^7.24.1","@vue/compiler-dom":"^3.4.27","@vue/compiler-sfc":"^3.4.27","@vuedx/template-ast-types":"0.7.1","fast-glob":"^3.3.2","prettier":"^3.2.5","typescript":"^5.4.5"},"devDependencies":{"@antfu/eslint-config":"^2.17.0","@babel/traverse":"^7.24.5","@types/babel__core":"^7.20.5","@types/babel__traverse":"^7.20.5","@types/node":"18.15.11","bumpp":"^9.4.1","eslint":"^9.2.0","npm-run-all":"^4.1.5","rimraf":"^5.0.7","tsup":"^8.0.2","vitest":"^1.6.0"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest","typecheck":"tsc -p tsconfig.json --noEmit","lint":"eslint .","lint:fix":"eslint . --fix","release":"bumpp package.json"},"_id":"@unovue/detypes@0.8.4","types":"./dist/index.d.ts","_integrity":"sha512-xbXzPFqdlQHS/kTMFGPPTl+dsGUL92ojrB/z8wQ9TKjuC9N1+sgnVivp7R5a0hMr2B47FjJVtz3yegXyu4MSOA==","_resolved":"/tmp/2393dd16b3c635a7b94fba0b03ffbc01/unovue-detypes-0.8.4.tgz","_from":"file:unovue-detypes-0.8.4.tgz","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-xbXzPFqdlQHS/kTMFGPPTl+dsGUL92ojrB/z8wQ9TKjuC9N1+sgnVivp7R5a0hMr2B47FjJVtz3yegXyu4MSOA==","shasum":"ffb2bcff58e4cf583e0a4b8e288494cd8cc27308","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@unovue/detypes/-/detypes-0.8.4.tgz","fileCount":11,"unpackedSize":61435,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCtrYXCgHkK9+15GNOPeJsQvlWnnPsYxgUh+RYY1V+AIgIhAOBH62ZtwUMtOhAg/648NQhYZHi7Hq1ZH2AMuvQiEc9l"}],"size":11105},"_npmUser":{"name":"anonymous","email":"zernonia@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"zernonia@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detypes_0.8.4_1728632570836_0.6651258948991317"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-11T07:42:50.997Z","publish_time":1728632570997,"_source_registry_name":"default","contributors":[]},"0.8.5":{"name":"@unovue/detypes","version":"0.8.5","description":"Removes TypeScript type annotations but keeps the formatting","author":{"name":"Zernonia","email":"zernonia@gmail.com"},"license":"MIT","homepage":"https://github.com/unovue/detypes#readme","repository":{"type":"git","url":"git+https://github.com/unovue/detypes.git"},"bugs":{"url":"https://github.com/unovue/detypes/issues"},"keywords":["typescript","formatting","vue","sfc"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"main":"dist/index.js","bin":{"detypes":"detype.js"},"engines":{"node":">=18"},"dependencies":{"@babel/core":"^7.24.5","@babel/preset-typescript":"^7.24.1","@vue/compiler-dom":"^3.4.27","@vue/compiler-sfc":"^3.4.27","@vuedx/template-ast-types":"0.7.1","fast-glob":"^3.3.2","prettier":"^3.2.5","typescript":"^5.4.5"},"devDependencies":{"@antfu/eslint-config":"^2.17.0","@babel/traverse":"^7.24.5","@types/babel__core":"^7.20.5","@types/babel__traverse":"^7.20.5","@types/node":"18.15.11","bumpp":"^9.4.1","eslint":"^9.2.0","npm-run-all":"^4.1.5","rimraf":"^5.0.7","tsup":"^8.0.2","vitest":"^1.6.0"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest","typecheck":"tsc -p tsconfig.json --noEmit","lint":"eslint .","lint:fix":"eslint . --fix","release":"bumpp package.json"},"_id":"@unovue/detypes@0.8.5","types":"./dist/index.d.ts","_integrity":"sha512-Yz4JeWOHGa+w/3YudVdng8hgN/VGW9cvp8xmFkmPPFzalGblLPPSpIRiwVo853yLstMZO2LLwe0vOoLAQsUQXw==","_resolved":"/tmp/6c3fe2a637e421d32c09fb7b9e2dec3b/unovue-detypes-0.8.5.tgz","_from":"file:unovue-detypes-0.8.5.tgz","_nodeVersion":"18.20.7","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Yz4JeWOHGa+w/3YudVdng8hgN/VGW9cvp8xmFkmPPFzalGblLPPSpIRiwVo853yLstMZO2LLwe0vOoLAQsUQXw==","shasum":"7e620319ad21a679dfdb18fcb7644b71041d6843","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@unovue/detypes/-/detypes-0.8.5.tgz","fileCount":11,"unpackedSize":61507,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHUw0N5on85SbXYhcf5zY9wN6zVgh88jr7fMYhVz58Z8AiEAiM/uoQNMgZ8sOnBH8kgDBqmi57PlmFom8PEK2jpWI08="}],"size":11113},"_npmUser":{"name":"anonymous","email":"zernonia@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"zernonia@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/detypes_0.8.5_1741588145915_0.14960860675435206"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-10T06:29:06.081Z","publish_time":1741588146081,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.8.5"},"name":"@unovue/detypes","time":{"created":"2024-10-11T04:38:19.486Z","modified":"2025-03-10T06:30:24.450Z","0.8.3":"2024-10-11T04:34:37.473Z","0.8.4":"2024-10-11T07:42:50.997Z","0.8.5":"2025-03-10T06:29:06.081Z"},"readme":"# detypes\n\n> Fork from https://github.com/Dunqing/detype, which is a fork from https://github.com/cyco130/detype. Since the original author has not processed the PR for a long time, a patch version has been released for the time being until original repo is active again.\n\n[![npm version](https://img.shields.io/npm/v/detypes.svg)](https://www.npmjs.com/package/detypes)\n[![npm downloads](https://img.shields.io/npm/dm/detypes.svg)](https://www.npmjs.com/package/detypes)\n\n```sh\nnpm i -g @unovue/detypes\n```\n\nSuppose you have a library that you want to provide usage examples for. **detypes** can help you generate vanilla JavaScript samples from TypeScript samples automatically and remove the burden of maintaining two separate versions of what is essentially the same code.\n\nIt is a command line tool and a library that removes type annotations and other TypeScript specific syntax constructs and outputs vanilla JavaScript **without altering the source formatting** too much. It supports `.ts`, `.tsx`, as well as `.vue` files.\n\nIn other words, it turns this:\n\n```ts\nimport type { ParsedPath } from 'node:path'\n\nlet x: string\n\n// This comment should be kept\n\n// This comment should be deleted\n// Ditto for this\ninterface Foo {\n  // This should go too\n  bar: number\n}\n\n// This comment should also be kept\nexport function bar(foo: Foo): Date {\n  return new Date()\n}\n```\n\ninto this:\n\n```js\nlet x\n\n// This comment should be kept\n\n// This comment should also be kept\nexport function bar(foo) {\n  return new Date()\n}\n```\n\nThe output is very close to hand-written JavaScript, especially if you were already using Prettier for formatting.\n\n## Doesn't `tsc` already do that?\n\nThere are lots of tools for transpiling TypeScript into plain JavaScript (`tsc`, `babel`, `swc`, `esbuild`, `sucrase` etc.) but none of them is perfectly suitable for this specific use case. Most of them don't preserve the formatting at all. `sucrase` comes close, but it doesn't remove comments attached to TypeScript-only constructs.\n\n`detypes` uses [Babel](https://babeljs.io/), a small Babel plugin to remove comments attached to TypeScript-only constructs, and [Prettier](https://prettier.io/) under the hood. For Vue files, it also uses the tools from the [VueDX project](https://github.com/vuedx/languagetools).\n\n## Magic comments\n\nSometimes you want the generated JavaScript to be slightly different than the TypeScript original. You can use the magic comments feature to achieve this:\n\nInput:\n\n```ts\n// @detypes: replace\n// These two lines will be removed\nconsole.log('Hello from TypeScript')\n// @detypes: with\n// // Notice the double comments!\n// console.log(\"Hello from JavaScript\");\n// @detypes: end\n```\n\nOutput:\n\n```js\n// Notice the double comments!\nconsole.log('Hello from JavaScript')\n```\n\nIf you just want to remove the magic comments, you can use the `-m` CLI flag or the `removeMagicComments` function to generate uncluttered TypeScript like this:\n\n```ts\n// These two lines will be removed\nconsole.log('Hello from TypeScript')\n```\n\n## System requirements\n\n`detypes` requires Node version 14.19.3 or later.\n\n## CLI Usage\n\n```\n  detypes [-m | --remove-magic-comments] <INPUT> [OUTPUT]\n\n    INPUT   Input file or directory\n\n    OUTPUT  Output file or directory\n      (optional if it can be inferred and it won't overwrite the source file)\n\n    -t, --remove-ts-comments\n      Remove @ts-ignore and @ts-expect-error comments\n\n    -m, --remove-magic-comments\n      Remove magic comments only, don't perform ts > js transform\n\n  detypes [-v | --version]\n\n    Print version and exit\n\n  detypes [-h | --help]\n\n    Print this help and exit\n```\n\n## Node API\n\n```ts\n// Transform TypeScript code into vanilla JavaScript without affecting the formatting\nfunction transform(\n// Source code\n  code: string,\n// File name for the source\n  fileName: string,\n// Options to pass to prettier\n  prettierOptions?: PrettierOptions | null,\n): Promise<string>\n\n// Transform the input file and write the output to another file\nfunction transformFile(\n  inputFileName: string,\n  outputFileName: string,\n): Promise<void>\n\n// Remove magic comments without performing the TS to JS transform\nexport function removeMagicComments(\n// Source code\n  code: string,\n// File name for the source\n  fileName: string,\n// Options to pass to prettier\n  prettierOptions?: PrettierOptions | null,\n): string\n\n// Remove magic comments from the input file and write the output to another file\nexport function removeMagicCommentsFromFile(\n  inputFileName: string,\n  outputFileName: string,\n): Promise<void>\n```\n\n## Change log\n\n### 0.6\n\n- feature: Option to remove @ts-ignore and @ts-expect-error comments\n- fix: Preserve newline runs (especially in template literals!)\n\n### 0.5\n\n- BREAKING CHANGE: Drop support for Node 12\n- chore: Set up CI workflows\n\n### 0.4\n\n- feature: CLI support for removing magic comments\n- chore: Improve documentation\n\n### 0.3\n\n- feature: Magic comments\n- feature: Expose type declarations\n- fix: Better empty line handling\n\n### 0.2\n\n- feature: for Vue single file components\n\n### 0.1\n\n- Initial release\n\n## Credits\n\nDunqing, Fatih Aygün, under MIT License","users":{}}