Volar TypeScript Twoslash Queries Service
This package integrates TypeScript Twoslash query capabilities directly into Volar-powered language services, enhancing developer tooling within Vue and other Volar-supported environments. It allows for inline type information and error checking queries within code comments, similar to how TypeScript's own playground functions. As of version 0.0.70, it is still in a pre-1.0 stage, indicating potential API changes but is actively maintained as part of the Volar ecosystem. Its release cadence is typically tied to Volar's own development cycle, meaning updates often coincide with new Volar releases or when new Twoslash features need integration. Key differentiators include its seamless integration into Volar's Language Server Protocol, providing rich type feedback without needing external tools or complex build steps for ad-hoc type queries directly within your editor.
Common errors
-
Cannot find module 'volar-service-typescript-twoslash-queries'
cause The package is not installed or the `require()`/`import` path is incorrect.fixRun `npm install volar-service-typescript-twoslash-queries` or `yarn add volar-service-typescript-twoslash-queries` in your project. -
TypeError: require(...).create is not a function
cause Attempting to call `create` incorrectly, potentially due to a mismatch between CommonJS and ESM module usage, or an incorrect import alias.fixFor CommonJS, use `require('volar-service-typescript-twoslash-queries').create()`. For ESM, use `import { create } from 'volar-service-typescript-twoslash-queries';` and then call `create()`. -
Service 'typescript-twoslash-queries' is not compatible with Volar version X.Y.Z
cause There is a version mismatch between this service package and your core `@volar/language-service` installation, leading to API incompatibility.fixUpdate `volar-service-typescript-twoslash-queries` to a version that specifically supports your `@volar/language-service` version. Consult the package's `peerDependencies` in `package.json`.
Warnings
- gotcha This package is currently in a pre-1.0 version (0.0.70), indicating its API surface may not be stable and could introduce breaking changes in minor versions. Always pin exact versions or review release notes carefully.
- breaking Compatibility with Volar's core language service is crucial. Major updates to `@volar/language-service` (e.g., v2.x to v3.x) often require corresponding updates to `volar-service-typescript-twoslash-queries` due to potential API changes in the Volar ecosystem.
Install
-
npm install volar-service-typescript-twoslash-queries -
yarn add volar-service-typescript-twoslash-queries -
pnpm add volar-service-typescript-twoslash-queries
Imports
- create
import volarTwoslashService from 'volar-service-typescript-twoslash-queries';
import { create } from 'volar-service-typescript-twoslash-queries'; - create
const volarTwoslashService = require('volar-service-typescript-twoslash-queries');const { create } = require('volar-service-typescript-twoslash-queries');
Quickstart
module.exports = {
services: [
require('volar-service-typescript-twoslash-queries').create(),
],
};