Framework for decorating a TypeScript language service with support for languages embedded inside template strings. Current stable version is 2.3.2, released July 2021. This library abstracts the complexity of handling template string nodes, allowing developers to focus on the embedded language's content. It is primarily used to build TypeScript language service plugins for tagged template literals (e.g., styled-components, lit-html). Unlike custom language service implementations, this decorator seamlessly integrates with TypeScript's existing infrastructure, handling offset mapping and template context automatically. It ships with TypeScript types and is ESM-and-CJS compatible. Release cadence is low; updates are infrequent and focus on maintenance.
npm install typescript-template-language-service-decoratorVerified import paths — ran on the pinned version, not inferred.
Shows a complete TypeScript server plugin that adds echo completions to template strings tagged with `echo`.
Import from 'typescript/lib/tsserverlibrary' instead of 'typescript'.
Implement the new optional method or update the interface to include it.
Parse text using `context.text.split(/\n/g)` or similar to get lines.
Update to use `ts.LineAndCharacter` object.
Use `import pkg from 'typescript-template-language-service-decorator'` with `esModuleInterop` enabled.
Change import to `import * as ts from 'typescript/lib/tsserverlibrary'`.
Use `import type { TemplateLanguageService } from 'typescript-template-language-service-decorator'`.Use `{ tags: ['myTag'], enabled: true }`.No dependency data recorded yet.