{"name":"typescript-template-language-service-decorator","version":"0.1.1","description":"Framework for decorating a TypeScript language service with support for languages embedded in template strings","keywords":["TypeScript","typescript server","plugin"],"author":{"name":"Microsoft"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Microsoft/typescript-template-language-service-decorator.git"},"bugs":{"url":"https://github.com/Microsoft/typescript-template-language-service-decorator/issues"},"main":"lib/index.js","types":"./lib/index.d.ts","files":["lib"],"dependencies":{},"devDependencies":{"@types/node":"^7.0.22","chai":"^4.1.2","glob":"^7.1.2","mocha":"^3.5.3","tslint":"^5.3.2","typescript":"^2.5.3"},"peerDependencies":{"typescript":"^2.3.0"},"scripts":{"compile":"tsc -p .","watch:compile":"tsc --watch -p .","e2e":"mocha e2e/tests/**/test.js"},"gitHead":"cbbea349830ee971dd070f795cd02ff2ebff85f3","homepage":"https://github.com/Microsoft/typescript-template-language-service-decorator#readme","_id":"typescript-template-language-service-decorator@0.1.1","_npmVersion":"5.0.3","_nodeVersion":"7.6.0","_npmUser":{"name":"mattbierner","email":"mattbierner@gmail.com"},"dist":{"integrity":"sha512-FnvTyMJEj2Zu9yvJRsA5yBG1uYyahsGlut5GF2LwWrwDGTuSwROuh4LjD19bxlBa0q2T50zD/z+eJaz3o8hClQ==","shasum":"33ff4a1966df8470752e9ff5232ed883f97b5804","tarball":"http://registry-npm.ywwl.com/typescript-template-language-service-decorator/download/typescript-template-language-service-decorator-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClSGMci/fjQT4ydSYNuG/sz5zIAfv/cf3EkkQqB9Y2OAIhAPoRtYC1FdZPqEkrbAcLaCuUnhd+mJFvX7sEIrmFvExo"}],"size":18479,"noattachment":false,"key":"/typescript-template-language-service-decorator/-/typescript-template-language-service-decorator-0.1.1.tgz"},"maintainers":[{"email":"npmjs@microsoft.com","name":"microsoft"},{"email":"mattbierner@gmail.com","name":"mattbierner"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typescript-template-language-service-decorator-0.1.1.tgz_1507699323175_0.36618871451355517"},"directories":{},"readme":"# TypeScript Template Language Service Decorator\n\nFramework for decorating a TypeScript language service with additional support for languages embedded inside of template strings.\n\n[![Build Status](https://travis-ci.org/Microsoft/typescript-template-language-service-decorator.svg?branch=master)](https://travis-ci.org/Microsoft/typescript-template-language-service-decorator)\n\n## Usage\nThis framework helps you to extend TypeScript's editor support for languages embedded inside of template strings. It hides most of the details of dealing with template strings so that you only have to worry about working with the template string contents themselves.\n\nSupport for embedded template languages is implemented using the `TemplateLanguageService` interface. Here's a simple `TemplateLanguageService` that adds completions that repeat the prior characters in a template string\n\n```ts\nimport { TemplateLanguageService, TemplateContext } from 'typescript-template-language-service-decorator';\n\nclass EchoTemplateLanguageService implements TemplateLanguageService {\n    getCompletionsAtPosition(\n        context: TemplateContext,\n        position: ts.LineAndCharacter\n    ): ts.CompletionInfo {\n        const line = context.text.split(/\\n/g)[position.line];\n        return {\n            isGlobalCompletion: false,\n            isMemberCompletion: false,\n            isNewIdentifierLocation: false,\n            entries: [\n                {\n                    name: line.slice(0, position.character),\n                    kind: '',\n                    kindModifiers: 'echo',\n                    sortText: 'echo'\n                }\n            ]\n        };\n    }\n}\n```\n\nThe `TemplateLanguageService` operates on the contents of template nodes. `context.text` for example returns the text content of the template string, and the `position` passed to `getCompletionsAtPosition` is relative to the template string body.\n\nThe `decorateWithTemplateLanguageService` method takes a existing TypeScript language service and decorates it with a `TemplateLanguageService`. Here's how you would use this method to create a simple TypeScript server plugin for the `EchoTemplateLanguageService`\n\n```ts\nimport * as ts from 'typescript/lib/tsserverlibrary';\nimport { decorateWithTemplateLanguageService } from 'typescript-template-language-service-decorator';\n\nexport = (mod: { typescript: typeof ts }) => {\n    return {\n        create(info: ts.server.PluginCreateInfo): ts.LanguageService {\n            return decorateWithTemplateLanguageService(\n                mod.typescript,\n                info.languageService,\n                info.project,\n                new EchoTemplateLanguageService(),\n                { tags: ['echo'] });\n        }\n    };\n};\n```\n\nThis plugin will now add echo completions to all template strings tagged with `echo`.\n\n\n## Examples\nFor more advanced examples of using this library:\n\n- [typescript-styled-plugin](https://github.com/Microsoft/typescript-styled-plugin)\n- [typescript-lit-html-plugin](https://github.com/mjbvz/typescript-lit-html-plugin)\n\n\n## Contributing\n\nTo build, you'll need [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/).\n\nFirst, [fork](https://help.github.com/articles/fork-a-repo/) the typescript-template-language-service-decorator repo and clone your fork:\n\n```bash\ngit clone https://github.com/YOUR_GITHUB_ACCOUNT_NAME/typescript-template-language-service-decorator.git\ncd typescript-template-language-service-decorator\n```\n\nThen install dev dependencies:\n\n```bash\nnpm install\n```\n\nThe plugin is written in [TypeScript](http://www.typescriptlang.org). The source code is in the `src/` directory with the compiled JavaScript output to the `lib/` directory. Kick off a build using the `compile` script:\n\n```bash\nnpm run compile\n```\n\nAnd then run the end to end tests with the `e2e` script:\n\n```bash\n(cd e2e && npm install)\nnpm run e2e\n```\n\nYou can submit bug fixes and features through [pull requests](https://help.github.com/articles/about-pull-requests/). To get started, first checkout a new feature branch on your local repo:\n\n```bash\ngit checkout -b my-awesome-new-feature-branch\n```\n\nMake the desired code changes, commit them, and then push the changes up to your forked repository:\n\n```bash\ngit push origin my-awesome-new-feature-branch\n```\n\nThen [submit a pull request](https://help.github.com/articles/creating-a-pull-request/\n) against the Microsoft typescript-template-language-service-decorator repository.\n\nPlease also see our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n\n## Credits\n\nCode originally forked from: https://github.com/Quramy/ts-graphql-plugin\n","publish_time":1507699323254,"_cnpm_publish_time":1507699323254,"dist-tags":{"latest":"2.3.2"}}