Jankat
Jankat

Reputation: 133

"Types are not supported by current JavaScript version" in PhpStorm

I'm working in PhpStorm on a Vue 2 / TypeScript project where whenever I want to include return types on functions I get "Types are not supported by current JavaScript version":

Types are not supported by current JavaScript version

On "Preferences > Languages and Frameworks > JavaScript", I have ECMAScript 6+ selected:

selected

I've tried restarting the IDE to no avail.

Any ideas?

Upvotes: 6

Views: 7216

Answers (2)

Hyder B.
Hyder B.

Reputation: 12186

I had the same error, but it happened because I was writing Typescript code in a .js file instead of .ts file.

  1. Rename .js to .ts
  2. Make sure you have the Javascript language version set to ECMAScript 6+ under Languages & Frameworks > Javascript in your Jetbrain IDE.

Upvotes: 3

Jankat
Jankat

Reputation: 133

Ah, apparently I was misled by the wording of the error message. Simply adding <script lang="ts"> inside my vue files has fixed it.

Upvotes: 6

Related Questions