WebStorm “当前 JavaScript 版本不支持 Let 定义”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39054143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 22:09:30  来源:igfitidea点击:

WebStorm “Let definition are not supported by current JavaScript version”

javascriptwebstorm

提问by AST

I am trying to use new tools available for coding in JavaScript. I've seen the post PhpStorm "Let definition are not supported by current JavaScript version". I've tried as suggested over there, but do not work.

我正在尝试使用可用于 JavaScript 编码的新工具。我看过PhpStorm的帖子“当前的 JavaScript 版本不支持让定义”。我已经按照那边的建议尝试过,但不起作用。

When I hover over the export

当我悬停在 export

Export declarations are not supported by current JavaScript version

当前 JavaScript 版本不支持导出声明

When I hover over the yield

当我悬停在 yield

Generators are not supported by current JavaScript version

当前 JavaScript 版本不支持生成器

and hovering over the let

并悬停在 let

Let definition are not supported by current JavaScript version

当前 JavaScript 版本不支持 Let 定义

So the question is how to upgrade the JavaScript version?

那么问题来了,如何升级 JavaScript 版本呢?

回答by YanMeng

It can be set up like in the following image:

可以如下图所示进行设置:

enter image description here

在此处输入图片说明

Flow:File -> Settings -> Languages & Frameworks -> Javascript

流程:文件 -> 设置 -> 语言和框架 -> Javascript

回答by newFinancier

Make sure you restart your IDE after changing the JS language version to ECMAScript 6.

将 JS 语言版本更改为 ECMAScript 6 后,请确保重新启动 IDE。

回答by Glen Pierce

You need to set your JavaScript version in the IDE. This can be accessed on Windows with ctrl + alt + s. You need at least ECMA Script 6 to use let.

您需要在 IDE 中设置 JavaScript 版本。这可以在 Windows 上使用 ctrl + alt + s 访问。您至少需要 ECMA Script 6 才能使用let.

回答by Serpearl

As others suggested, setting the language version does fix this:

正如其他人所建议的,设置语言版本确实可以解决这个问题:

File -> Settings -> Languages & Frameworks -> Javascript

File -> Settings -> Languages & Frameworks -> Javascript

However, that was not enough in my case. If you're experiencing these errors in a project that is nested within another project you must apply the JS language settings to the parent projectas well.

然而,这对我来说还不够。如果您在嵌套在另一个项目中的项目中遇到这些错误,您还必须将 JS 语言设置应用于父项目

In my case, it was a client-side React app nested inside a larger Java-based web-portal (Working with IntelliJ IDEA Ultimate, which uses the same settings flow). I am adding this answer to the discussion in the hope that it can help someone in the future.

就我而言,它是一个嵌套在基于 Java 的更大网络门户中的客户端 React 应用程序(使用 IntelliJ IDEA Ultimate,它使用相同的设置流程)。我将此答案添加到讨论中,希望它可以在将来对某人有所帮助。

回答by VIKAS KOHLI

You have to change the settings for using this keyword

您必须更改使用此关键字的设置

Go to File -> Settings -> Languages & Frameworks -> Javascript (Select ECMA Script 6)

转到文件 -> 设置 -> 语言和框架 -> Javascript(选择 ECMA Script 6