Migration Guide
Mirgrating from @typescript/twoslash
.
Consider twoslash
as the successor of @typescript/twoslash
that maintained and driven by the community. It has been rewritten to provide better performance and more flexible APIs.
Breaking Changes
Breaking changes from @typescript/twoslash
:
- The returned items have different signatures, and different types of the items (
staticQuickInfo
,queries
,errors
,tags
) are now unified into a single arraynodes
. Learn more at the Information Nodes section. - Main entry point
import "twoslash"
importstypescript
, while a new sub-entryimport "twoslash/core"
is dependency-free and requires providing your own typescript instance. defaultOptions
is renamed tohandbookOptions
defaultCompilerOptions
is renamed tocompilerOptions
playgroundURL
is removed
Compatibility Layer
To make it easier to migrate from @typescript/twoslash
, we provided a backward compatibility layer that allows you to use the old interface with the new implementation.
ts
import { twoslasherLegacy } from 'twoslash'
const result = twoslasherLegacy('import { ref } from "vue"', 'ts')
console.log(result.staticQuickInfos) // the old interface
You can also compose it your own by only converting the return value:
ts
import { convertLegacyReturn, twoslasher } from 'twoslash'
const result = twoslasher('import { ref } from "vue"', 'ts') // new interface
const legacy = convertLegacyReturn(result) // <--
console.log(legacy.staticQuickInfos) // the old interface