coatesap
coatesap

Reputation: 11127

PhpStorm warns about Object methods in Vue component when using TypeScript

When creating Vue components using TypeScript (via the lang="ts" attribute of the script tag), PhpStorm (version 2021.2.2) shows a warning about any methods of the native JavaScript Object as "Unresolved function or method", e.g.:

<template>
  ...
</template>

<script lang="ts">
const v = Object.values({ a: 'a', b: 'b' });
</script>

Results in:

Screenshot of PhpStorm highlighting Object.values as undefined

How can PhpStorm (or WebStorm) be configured to recognise Object as the native JS ES6+ Object?

(For reference, Cmd + clicking on Object jumps to lib.es5.d.ts so it's assuming the wrong version of JavaScript. However, under Languages & Frameworks > JavasScript, the version is already set to ECMAScript 6+)

Upvotes: 1

Views: 547

Answers (1)

lena
lena

Reputation: 93728

Object.values() is part of ES2017. Make sure to either set "target" to "esnext" or add "esnext" to "lib": [] in tsconfig.json

enter image description here

Upvotes: 1

Related Questions