首页 文章

TypeScript,Vue和experimentalDecorators

提问于
浏览
0

我已经通过Vue-CLI v3.0.0-beta.15创建了一个Vue项目,现在,一切正常,我的意思是,当我执行 npm run serve 它编译并运行正常但是TypeScript会抛出以下错误消息并且 only inside the editor!

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

The things I've tried and didn't work:

  • 我仔细检查 experimentalDecorators 在我的 tsconfig.json 文件中是否设置为true,默认情况下为Vue .

  • 我尝试使用以下选项创建 jsconfig.json 文件:

{
    "compilerOptions": {
        "experimentalDecorators": true
    }
}
  • 我试图在VSCode "javascript.implicitProjectConfig.experimentalDecorators": true 中更改以下选项

现在,我正在使用VSCode的Vetur扩展,我已经在他们的repo but I don't use any extensions with Visual Studio for Vue and yet I get the same error 上发布了issue所以我不会't know what triggers it but I think that something doesn' t选择 tsconfig.json 文件 .

Here are the steps I've taken to generate the project:

  • mkdir实验&& cd $ _

  • npm init

  • npm install -D @vue/cli

  • ./node_modules/.bin/vue创建仪表板

  • 我使用了以下选项:

  • 检查项目所需的功能:Babel,TS,PWA,路由器,Vuex,CSS预处理器,Linter,Unit,E2E

  • 使用类样式的组件语法?是

  • 使用Babel和TypeScript进行自动检测的polyfill?是

  • 选择CSS预处理器(默认支持PostCSS,Autoprefixer和CSS模块):SCSS / SASS

  • 选择linter / formatter配置:TSLint

  • 选择其他lint功能:保存时提示

  • 选择单元测试解决方案:摩卡

  • 选择E2E测试解决方案:赛普拉斯

  • 你喜欢在哪里为Babel,PostCSS,ESLint等配置?在专用配置文件中

  • 将此保存为未来项目的预设?没有

  • 然后导航到dashboard / src / views / Home.vue

这就是它在_180471中的样子:

这就是_180472中的样子:

2 回答

  • 0

    你见过这个post吗?

    也许你应该尝试:转到File => Preferences => Settings(或Control comma),它将打开用户设置文件 . 添加“javascript.implicitProjectConfig.experimentalDecorators”:true

    EDIT :

    好的,在您的第一个例子中,您已在 experiment 目录中打开了项目,但tsconfig.json位于子目录中,tsconfig必须位于根目录中 . 尝试使用 dashboard 打开vscode作为vscode项目的根文件夹,然后重新启动编辑器 .

  • 1

    事实证明,我必须在 tsconfig.json 文件所在的文件夹的根目录下创建 jsconfig.json ,并且Visual Studio中的错误消失,但VSCode仍然显示错误,而不管选项I 've set but this seems like it' sa Vetur bug而不是VSCode中的错误,TypeScript或配置问题 .

    打开 Dashboard 文件夹而不是 Src 文件夹,这是我项目的实际根目录"fixed" VSCode中的问题,所以我猜Vetur在嵌套时不会选择 tsconfig.json 文件 .

相关问题