Skip to content

twoslash 类型提示功能

typescript 类型提示

类型提示来自于 @shikijs/vitepress-twoslash 包。

封装好的 config.mts 配置
ts
interface Person {
	
name
: string;
age
: number;
} const
person
: Person = {
name
: "John",
age
: 20,
};

编写语法如下:

markdown
<<< ./twoslash-example-code.ts{ts twoslash}

这里是按照相对路径的方式导入文档的。

在 vitepress 导入代码块的基础上,增加后面的尾缀即可。

尾缀选择

有两种尾缀可以触发 twoslash 。

贡献者

The avatar of contributor named as ruan-cat ruan-cat

页面历史

最近更新