[英]How can I use JavaScript private fields in VS Code?
I'm using the proposed private field syntax in my JavaScript but VS Code says this is a syntax error:我在 JavaScript 中使用了提议的私有字段语法,但 VS Code 说这是一个语法错误:
The specific error is: Invalid character. ts(1127)
具体错误是:
Invalid character. ts(1127)
Invalid character. ts(1127)
How can I make VS Code understand private fields?如何让 VS Code 理解私有字段?
VS Code uses the TypeScript project to power both its JavaScript and TypeScript IntelliSense. VS Code 使用TypeScript 项目为其 JavaScript 和 TypeScript IntelliSense 提供支持。 The TypeScript project only added support for private fields in TypeScript 3.8 .
TypeScript 项目仅在 TypeScript 3.8 中添加了对私有字段的支持。 However the current release of VS Code (1.41) only includes the latest stable TypeScript 3.7 release.
然而,当前版本的 VS Code (1.41) 仅包含最新的稳定版 TypeScript 3.7。
If you see syntax errors for private fields, you are likely using a version of TypeScript in VS Code that does not yet understand private fields.如果您看到私有字段的语法错误,则您可能在 VS Code 中使用了尚不理解私有字段的 TypeScript 版本。
VS Code 1.43 (to be released early March 2020) will include TypeScript 3.8. VS Code 1.43(将于 2020 年 3 月上旬发布)将包含 TypeScript 3.8。 Until then, you can upgrade your workspace to use a newer typescript version by either:
在此之前,您可以通过以下任一方式升级您的工作区以使用更新的打字稿版本:
Installing this extension安装这个扩展
Following these instructions按照这些说明
Keep in mind that other VS Code extensions—such as linters—may also need to be updated with support for private fields请记住,其他 VS Code 扩展(例如 linter)也可能需要更新以支持私有字段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.