{"_id":"tsc-template","_rev":"7-e3ba82e6b72a972d13bb475af274bb35","name":"tsc-template","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"tsc-template","version":"0.1.0","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.1.0","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"9eb0641f36995b2b2bccdf0521519bc2b9fc3084","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.1.0.tgz","fileCount":15,"integrity":"sha512-T9M1JuIyjwKjsdNQTi9Cu+6zbbcJQAhGbrkCq7ryzI2w8zix9tLocKI9BMU2QmcOLoxxkxRSPF34Dkjc5bSd7g==","signatures":[{"sig":"MEQCIBDDPTZIt4qSFkQWMzJhrKVikq0QWSVW6x9pVSuyZjnhAiAt8a3hCW50xESMRn+9RsfIzJTLWSz06P/7RmpRu/Q1sQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25433},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"a424c01be49f4f4c76b86f838d82691322dc2b19","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.8.1","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.4.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.1.0_1739384177595_0.42161778890887325","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"tsc-template","version":"0.1.1","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.1.1","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"3d58adbbcb80e987adecf79c74b44c1170b4badc","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.1.1.tgz","fileCount":19,"integrity":"sha512-s7YDPuJPdrugc8zu88LOg/FdK+PLAz0MtzEwflgMqB90RBL6r9nXV/W1Pkkzyh4xWD9fcIxcr9wD3mNGt9KKug==","signatures":[{"sig":"MEUCIQDgHRTv0DcsOdxl/wSrwX8utYWKZMr0b6HOj8/9y4u2lQIgNC8l5U8Wn03LobK0V7Awmdt8gzymvkyf2GAiEiSxgJI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27381},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"32799eecbe667da8e9823a7e53623adc4c6e84ec","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.8.1","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.4.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.1.1_1739385244034_0.37801170488103186","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"tsc-template","version":"0.1.2","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.1.2","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"656c5a79f2af229eacba921fddb777fb2dd43c2b","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.1.2.tgz","fileCount":19,"integrity":"sha512-WLebWdwyUU10y5OKMHVawHOUJB+YT7n4JiSClSjkSgjeAAohOSZcyHOTKmPGn6ZO+9NIPS3FPtTykp9fT2htjw==","signatures":[{"sig":"MEUCIBJuCzZsh81V35WZhZXGwS5I4zV6imtDCfQUOAMT4xWDAiEApvhHn5MlB6W5kl3P5VhA72i4mA1ASCJl+Kg5qxUzqRA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27645},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"9a7e7ee100b1e530f4e0a3b2359b19146f6e4fee","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.8.1","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.4.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.1.2_1739395877665_0.8141472625142059","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"tsc-template","version":"0.2.0","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.2.0","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"e2062ae5ea9bfa884a7d92f576f7ab61652592ff","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.2.0.tgz","fileCount":23,"integrity":"sha512-/YXScyQx220SKUlPZ+DVlJsbp/9SArZiLvVFzVPGgnzJ+LeG/tg6ldToc0cmB98yh/hwrSQniHx2+AR9maUnxQ==","signatures":[{"sig":"MEUCIQCycUxahXzsfV1C2Hb3N+syQzryrNfxhWpNNRwhV5BQVQIgTC5abhm/qM+/F4Jy1WYKo8HPJfF0UFoQN2D9Pb37NUc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30370},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"b794d8e1dfbdad06912119fead314db4f8865e8e","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.9.2","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.2.0_1739454735236_0.18698961886816368","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"tsc-template","version":"0.2.1","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.2.1","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"23ff5d1dad1e2b098793f959271764387004090e","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.2.1.tgz","fileCount":23,"integrity":"sha512-oN8Pe7eTrKPurCbVtxyZcmHPTtlyA8/LBdmjFtkxyms+1P4WNJ53nbMDFU63Es5tPrhDV9XMvnqJm+FbrlcRbg==","signatures":[{"sig":"MEQCIDk70z1A6zDYGVbMhd72vYPzT1/83WvYfie7cQjGDxgpAiBYK8k0tb/wxWpLc52q+ParJuozaTAmMf84m5HEYaWD/w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30396},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"ad5fcf539e34ed845341f5d86295867ae15bfcf6","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.9.2","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.2.1_1739456450131_0.9287967305405656","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"tsc-template","version":"0.2.2","keywords":["typescript","util","template","ast"],"author":{"url":"https://github.com/Lodin","name":"Vlad Rindevich","email":"vladrin@vaadin.com"},"license":"Apache-2.0","_id":"tsc-template@0.2.2","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"homepage":"https://github.com/ausginer/tsc-template#readme","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"dist":{"shasum":"b78e9dd4e8f8668fcc51ef281e196ffebf870952","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.2.2.tgz","fileCount":23,"integrity":"sha512-+81A7AFfvf3UFEsCBZFvFVMEPj/AqrWMPnLOT9/bQkQgJ6Zt+XKQnOwgKSzFYw4Ysi0Sv8w8e7eSOgFoLbtimw==","signatures":[{"sig":"MEUCIQDuhqifnljg+RJ8l/H6dXEYvpe5Ul3I1pdeTJ0GV+hnsgIgF32H8LxBaIBfXys8urkM+PmFq5lhgNb1yAJv1iLVSNc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30318},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"d026e8939b5b7951ffa2ca7b820a68d4e3405234","scripts":{"test":"vitest --run","build":"tsc -p tsconfig.build.json","clean":"git clean -fx . -e .vite -e .idea -e node_modules","prepare":"npm run build","test:coverage":"vitest --run --coverage"},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"repository":{"url":"git+https://github.com/ausginer/tsc-template.git","type":"git"},"_npmVersion":"10.9.2","description":"Utility to build TypeScript AST from a string, similar to @babel/template","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","chai":"5.1.2","eslint":"8.57.0","vitest":"3.0.5","prettier":"3.5.0","chai-like":"1.1.3","@types/chai":"5.0.1","@types/node":"22.13.1","@types/chai-like":"1.1.3","@vitest/coverage-v8":"3.0.5","eslint-plugin-tsdoc":"0.4.0","eslint-config-vaadin":"1.0.0-alpha.28"},"peerDependencies":{"typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/tsc-template_0.2.2_1741793031561_0.21042564581730527","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"tsc-template","version":"0.2.3","description":"Utility to build TypeScript AST from a string, similar to @babel/template","main":"index.js","type":"module","scripts":{"prepare":"npm run build","clean":"git clean -fx . -e .vite -e .idea -e node_modules","build":"tsc -p tsconfig.build.json","test":"vitest --run","test:coverage":"vitest --run --coverage"},"repository":{"type":"git","url":"git+https://github.com/ausginer/tsc-template.git"},"keywords":["typescript","util","template","ast"],"author":{"name":"Vlad Rindevich","email":"vladrin@vaadin.com","url":"https://github.com/Lodin"},"license":"Apache-2.0","bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"homepage":"https://github.com/ausginer/tsc-template#readme","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"peerDependencies":{"typescript":"5"},"devDependencies":{"@types/chai":"5.0.1","@types/chai-like":"1.1.3","@types/node":"22.13.1","@vitest/coverage-v8":"3.0.5","chai":"5.1.2","chai-like":"1.1.3","eslint":"8.57.0","eslint-config-vaadin":"1.0.0-alpha.28","eslint-plugin-tsdoc":"0.4.0","prettier":"3.5.0","tsx":"4.19.2","vitest":"3.0.5"},"_id":"tsc-template@0.2.3","gitHead":"0137068d1bf9dbb71bc1123f38215372388e82d3","types":"./index.d.ts","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-wuT2Rxl16IfqVAQv2EuJr56nZXACR8Nda2VFNSL+VL2K3XhBKr5cF6ccoW8CvOEyTv11BHuAmT2WWxfCEjJUBA==","shasum":"4c952aefeb60cfc9e057827156156f3d93304df1","tarball":"https://registry.npmjs.org/tsc-template/-/tsc-template-0.2.3.tgz","fileCount":23,"unpackedSize":30382,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEl6GjCjXMvT2m47ZU6KawQCj6jMgqHjwojgTCjb7QtgAiEAo16uBoK/wmJ3CC8wXNjCg45pIpvnu+brFmiKZKbxRtk="}]},"_npmUser":{"name":"lodin","email":"vladrin@vaadin.com"},"directories":{},"maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tsc-template_0.2.3_1742480077730_0.01100893235638356"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-12T18:16:17.594Z","modified":"2025-03-20T14:14:38.157Z","0.1.0":"2025-02-12T18:16:17.843Z","0.1.1":"2025-02-12T18:34:04.265Z","0.1.2":"2025-02-12T21:31:17.884Z","0.2.0":"2025-02-13T13:52:15.459Z","0.2.1":"2025-02-13T14:20:50.320Z","0.2.2":"2025-03-12T15:23:51.779Z","0.2.3":"2025-03-20T14:14:37.968Z"},"bugs":{"url":"https://github.com/ausginer/tsc-template/issues"},"author":{"name":"Vlad Rindevich","email":"vladrin@vaadin.com","url":"https://github.com/Lodin"},"license":"Apache-2.0","homepage":"https://github.com/ausginer/tsc-template#readme","keywords":["typescript","util","template","ast"],"repository":{"type":"git","url":"git+https://github.com/ausginer/tsc-template.git"},"description":"Utility to build TypeScript AST from a string, similar to @babel/template","maintainers":[{"name":"lodin","email":"vladrin@vaadin.com"}],"readme":"## tsc-template\n\nThis project provides utilities to facilitate the creation and manipulation of TypeScript Abstract Syntax Trees (ASTs). The key utility is the `ast` function that works similarly to the [@babel/template](https://babeljs.io/docs/babel-template) package but for TypeScript. \n\n### Installation\n\nTo install the project, run:\n\n```bash\nnpm install tsc-template\n```\n\n### Features\n\n#### AST Generation\n**Easily create TypeScript ASTs from template strings.**\n\nThe creation of TypeScript AST is not trivial and has nuances. To simplify that, you can use `ast` function that consumes a string and returns an AST for it.\n\n```ts\nimport ast from 'tsc-template';\nimport { isSourceFile } from 'typescript';\n\nconst file = ast`const foo = [1, 2, 3]`;\nassert(isSourceFile(file));\nassertEqual(file.getText(), 'const foo = [1, 2, 3]');\n```\n\n#### Mix of String and AST Nodes\n**Use TypeScript nodes directly in the code as if they are simple strings.**\n\nWhen you work with massive TS generation, sometimes you need to use nodes created in one place, in another. With the plain TypeScript, you would need to create a TS transformer or create all the tree manually. However, with power of template literals, you can use the nodes directly in the code you provide to `ast` function.\n\n```ts\nimport ast from 'tsc-template';\nimport { factory } from 'typescript';\n\nconst fooId = factory.createIdentifier('foo');\nconst file = ast`const ${fooId} = [1, 2, 3]`;\n\nassertEqual(file.getText(), 'const foo = [1, 2, 3]');\n```\n\n#### Smart Result Injection\n**Inject the result of one `ast` function to another; no complex selectors required.**\n\nWhat if you have created a good chunk of the code using the `ast` function and want to inject it into another chunk? No problem: just use the result of one `ast` function as a part of another! The smart injection system will find the correct node, so you don't need to create complex selectors.\n\n```ts\nimport ast from 'tsc-template';\n\nconst file = ast`const foo = ${ast`[1, 2, 3]`}`;\n\nassertEqual(file.getText(), 'const foo = [1, 2, 3];');\n```\n\n#### Tags for Custom AST Extractions\n**Use extractor tags to select only a part of the code you need.**\n\nSometimes, the code you can create via `ast` function is represented incorrectly in TypeScript AST. E.g., when you declare a function in the module root, it will be `FunctionDeclaration` while the function assigned to the variable is `FunctionExpression`. What to do? \n\nIt's simple. Use extractor tags! `%{` and `}%` would allow you to select the correct part of the code you want to have as AST.\n\n```ts\nimport ast from 'tsc-template';\n\nconst functionExpression = ast`const b = %{ function b() {} }%`;\nconst file = ast`const x = ${functionExpression}`;\nassertEquals(file.getText(), 'const x = function b() {};');\n```\n\n### License\n\nThis project is licensed under the Apache-2.0 License.","readmeFilename":"README.md"}