{"_id":"@autumnblaze/typescript-simple","name":"@autumnblaze/typescript-simple","dist-tags":{"latest":"9.0.0"},"versions":{"9.0.0":{"name":"@autumnblaze/typescript-simple","description":"Simple API to compile TypeScript code string to JavaScript. That's all!","version":"9.0.0","author":{"name":"Teppei Sato","email":"teppeis@gmail.com"},"engines":{"node":">=6"},"main":"index.js","dependencies":{"typescript":"^5.0.3"},"devDependencies":{"@types/node":"^6.0.111","mocha":"^5.2.0","pkg-up":"^2.0.0","semver":"^5.5.0"},"homepage":"https://github.com/teppeis/typescript-simple","repository":{"type":"git","url":"git+https://github.com/teppeis/typescript-simple.git"},"bugs":{"url":"https://github.com/teppeis/typescript-simple/issues"},"keywords":["typescript"],"license":"MIT","scripts":{"build":"tsc","test":"npm run prepare && mocha"},"types":"./index.d.ts","_id":"@autumnblaze/typescript-simple@9.0.0","_integrity":"sha512-YQY01/xlPRSpdUkVRj+IL5yjURi1lk1Wi+3piwEYEJyLunUbe3zAWvyUhZSfHAveOIp8FL+UPiJg8gk2oGIFCw==","_resolved":"/private/var/folders/fm/_3jg9ntn48vgljy480zz9dw00000gn/T/65227403a9ec03996cc3b2758dacbe1e/autumnblaze-typescript-simple-9.0.0.tgz","_from":"file:autumnblaze-typescript-simple-9.0.0.tgz","_nodeVersion":"18.12.1","_npmVersion":"9.6.2","dist":{"integrity":"sha512-YQY01/xlPRSpdUkVRj+IL5yjURi1lk1Wi+3piwEYEJyLunUbe3zAWvyUhZSfHAveOIp8FL+UPiJg8gk2oGIFCw==","shasum":"2cb6dbe4174df94c7d4e367497160017f622831f","tarball":"https://registry.npmjs.org/@autumnblaze/typescript-simple/-/typescript-simple-9.0.0.tgz","fileCount":14,"unpackedSize":46879,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbD9CZhr/n9yAgl2tPPWzvrE2V+tXUTEibhwNg0J5PPAIhAIzVKB9ses+CJVUtqoba2TzikQMdaErIStUSSKHkNdB1"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkK26cACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo3nA/9EQSVa+z9J4a1T8Pj5TlXYpuvwy3AExi2gMlhDIhYtqIHUk6B\r\no9W+N/JBAmEQDumt1QYGyiq3/kLpyDX5YfjTyBy8LdEGCIqtw8TH0F8dtF8H\r\n8AlW2Kz3MCPvo+AJCbOBFz/5vnSiZlMkCh0LPwmjTiBViXepYhFuorNuU5iR\r\nEHDX4hSoSFFkpWu+EAxcy8ukppoU+5e91R6TlmB8rvwpARRGQiNrRz2YAm8v\r\nyMxtVFQjMH5nDB03CGf2PJgoeFLtHoIGsh6ZX7A4ql2ewrEu39LIEVCNUM52\r\n83CEfpFbHUzMgCgjhQSMjXrhw43lt82tpZ6mnF8ixrtGVuFREYknC7wI1blU\r\nU1yrWya037vtx4ufk6r26hxFx3z0/C+HsncQ3xKl59HKvKjsmBC7R7n0zz2N\r\nEjBJ8DcI0FjjpRb8CbaZJY2Iy6rHpAIi4PZlgrzEwBw6rF26lczgIkSRB62W\r\nE/S8Wv7igAsqlsZEG/2QIKU21zXQ37S0fE8WySunWnOS3WG2tlC37Rxsu42B\r\nx7Bqm7Wbpqi5lPs9jZ7u+fxpNmECMDiQbpA5OpYE+kgAMin6jWuax1CCGu3I\r\ni6fITLB2QzQdLbqh/dJ6YJyklia/xLfIXNcNjb81OQMSdlEVb+xQnAZiCS85\r\nkfJ3yaYURk85XQ2JLzTrQPbuLPuMa47Vqq8=\r\n=wNpC\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"autumnblaze","email":"liujalexander84@gmail.com"},"directories":{},"maintainers":[{"name":"autumnblaze","email":"liujalexander84@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typescript-simple_9.0.0_1680567963947_0.9018116738055668"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-04T00:26:03.839Z","9.0.0":"2023-04-04T00:26:04.198Z","modified":"2023-04-04T00:26:04.383Z"},"maintainers":[{"name":"autumnblaze","email":"liujalexander84@gmail.com"}],"description":"Simple API to compile TypeScript code string to JavaScript. That's all!","homepage":"https://github.com/teppeis/typescript-simple","keywords":["typescript"],"repository":{"type":"git","url":"git+https://github.com/teppeis/typescript-simple.git"},"author":{"name":"Teppei Sato","email":"teppeis@gmail.com"},"bugs":{"url":"https://github.com/teppeis/typescript-simple/issues"},"license":"MIT","readme":"typescript-simple\n======\n\nSimple API to compile TypeScript code string to JavaScript. That's all!\n\n[![npm version][npm-image]][npm-url]\n[![npm downloads][npm-downloads-image]][npm-url]\n![Node.js Version Support][node-version]\n[![build status][circleci-image]][circleci-url]\n[![windows build status][appveyor-image]][appveyor-url]\n[![dependency status][deps-image]][deps-url]\n![License][license]\n\n## Description\n\n`typescript-simple` provides just one method that accepts TypeScript code string and returns JavaScript code.\n\n### Why?\n\n* TypeScript v1.4 doesn't have simple TS string to JS string API\n* TypeScript v1.5 has [ts.transpile()](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function), but it cannot generate source map\n* TypeScript v1.6+ has [ts.transpile()](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function) with source map, but it always ignores type checking\n\n## Versioning\n\n* typescript-simple v8.x.x uses TypeScript v2.2 - v2.9\n* typescript-simple v7.x.x uses TypeScript v2.1\n* typescript-simple v6.x.x uses TypeScript v2.0\n* typescript-simple v5.x.x uses TypeScript v1.8\n* typescript-simple v4.x.x uses TypeScript v1.7\n* typescript-simple v3.x.x uses TypeScript v1.6\n* typescript-simple v2.x.x uses TypeScript v1.5\n* typescript-simple v1.x.x uses TypeScript v1.4\n\nNote: typescript-simple updates the major version for TypeScript's minor update including breaking changes.\n\n## Install\n\n```console\n$ npm install typescript-simple\n```\n\n## Usage\n\nSimple usage (default target is ES5).\n\n```javascript\nvar tss = require('typescript-simple');\nvar js = tss('var n: number = 1;');\nconsole.log(js); // 'var n = 1;'\n```\n\nIf the code causes errors, `typescript-simple` throws errors.\n\n```javascript\ntry {\n    var js = tss('var n: number = \"str\";');\n} catch (e) {\n    console.error(e); // Error: L1: Type 'string' is not assignable to type 'number'.\n}\n```\n\n### Compiler Options\n\nSpecify [CompilerOptions](https://github.com/Microsoft/TypeScript/blob/0f67f4b6f1589756906782f1ac02e6931e1cff13/lib/typescript.d.ts#L1445-L1500) at 2nd argument.\n\n```javascript\nvar js = tss('var n: number = 1;', {noImplicitAny: true});\n```\n\n### Make repeated compilation faster\n\n`tss()` with options is not best-performance-method to be executed many times.\nUse `TypeScriptSimple` class for this purpose.\n\n```javascript\nvar TypeScriptSimple = require('typescript-simple').TypeScriptSimple;\nvar tss = new TypeScriptSimple({target: ts.ScriptTarget.ES6, noImplicitAny: true});\nvar js1 = tss.compile('var n: number = 1;');\nvar js2 = tss.compile('var s: string = \"foo\";');\n```\n\n### Ignore semantic errors\n\nIf you don't need TypeScript *semantic* error and just want the result code, give 2nd argument of the constructor `false`.\n\n```javascript\nvar tss = new TypeScriptSimple({target: ts.ScriptTarget.ES6}, false);\nvar js = tss.compile('var n: string = 1;'); // an error is not thrown.\n```\n\nNote: *syntactic* errors may be thrown.\n\n### JSX (.tsx)\n\n- `--jsx=preserve`\n\n```javascript\nvar jsx = tss.compile('var foo: any = <Foo />;', {jsx: ts.JsxEmit.Preserve});\nconsole.log(jsx); // 'var foo = <Foo />;'\n```\n\n- `--jsx=react`\n\n```javascript\nvar tss = new TypeScriptSimple({jsx: ts.JsxEmit.React}, false);\nvar js = tss.compile('var foo: any = <Foo />;');\nconsole.log(js); // 'var foo = React.createElement(\"Foo\", null);'\n```\n\nNote: Ignore semantic errors if you use `JsxEmit.React`.\n\n### Source map\n\nInline source map is available.\n\n```javascript\nvar tss = new TypeScriptSimple({sourceMap: true});\nvar js = tss.compile('var n: number = 1;', 'path/to/file.ts');\n```\n\nOutput:\n\n```javascript\nvar n = 1;\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI...\n```\nNote: The path to file doesn't need to be an actual file. We just copy the contents of the passed in ts string into the inline sourceMap and make it look like the js is coming from a ts file at that file path.\n\n## Limitations\n\n`typescript-simple` cannot compile multiple source files.\n\n## API\n\nSee [index.d.ts](index.d.ts).\n\n## Contributors\n\n* [@basarat](https://github.com/basarat)\n\n## License\n\nMIT License: Teppei Sato &lt;teppeis@gmail.com&gt;\n\n[npm-image]: https://img.shields.io/npm/v/typescript-simple.svg\n[npm-url]: https://npmjs.org/package/typescript-simple\n[npm-downloads-image]: https://img.shields.io/npm/dm/typescript-simple.svg\n[travis-image]: https://img.shields.io/travis/teppeis/typescript-simple/master.svg\n[travis-url]: https://travis-ci.org/teppeis/typescript-simple\n[deps-image]: https://img.shields.io/david/teppeis/typescript-simple.svg\n[deps-url]: https://david-dm.org/teppeis/typescript-simple\n[node-version]: https://img.shields.io/badge/Node.js%20support-v6,v8,v10-brightgreen.svg\n[coverage-image]: https://img.shields.io/coveralls/teppeis/typescript-simple/master.svg\n[coverage-url]: https://coveralls.io/github/teppeis/typescript-simple?branch=master\n[license]: https://img.shields.io/npm/l/typescript-simple.svg\n[appveyor-image]: https://ci.appveyor.com/api/projects/status/22nwyfaf5p0yw54j/branch/master?svg=true\n[appveyor-url]: https://ci.appveyor.com/project/teppeis/typescript-simple/branch/master\n[circleci-image]: https://circleci.com/gh/teppeis/typescript-simple.svg?style=shield\n[circleci-url]: https://circleci.com/gh/teppeis/typescript-simple\n","readmeFilename":"README.md"}