BuptStEve / vuepress-plugin-demo-code

📝 Demo and code plugin for vuepress
https://buptsteve.github.io/vuepress-plugin-demo-code/
MIT License
124 stars 28 forks source link

feat:支持typescript #40

Closed Yan2603 closed 2 years ago

BuptStEve commented 2 years ago

你指用 ts 重写么?

Yan2603 commented 2 years ago

你指用 ts 重写么?

不是的,我的demo是用TS写的,就运行不起来了。

BuptStEve commented 2 years ago

你指用 ts 重写么?

不是的,我的demo是用TS写的,就运行不起来了。

用的 vuepress2 么? 上个图,或者给个复现仓库?

BuptStEve commented 2 years ago

要想不报错可以这么写

export default defineConfig({
  plugins: [
    ['vuepress-plugin-demo-code', {}],
  ]
});

如果要参数类型提示可以这么写

import { defineConfig } from "vuepress/config";
import { DemoCodePluginOptions } from "vuepress-plugin-demo-code";

const demoCodeOptions: DemoCodePluginOptions = {
  // ...
};

export default defineConfig({
  plugins: [
    ['vuepress-plugin-demo-code', demoCodeOptions],
  ],
});