For my project, I have implemented TypeScript. While JavaScript's array includes() function has been valid since ECMA6, setting the lib
parameter in tsconfig
to "es6"
results in a non-fatal error being thrown in the browser console when using the following code:
['alpha', 'beta', 'gamma'].includes('alpha');
The non-fatal error displayed is:
[default] /foo/bar.component.ts:157:28
Property 'includes' does not exist on type 'string[]'.
To resolve this issue, simply changing the lib
parameter in tsconfig
to es7
will silence the error in the console, ensuring smooth functionality of the code.
Despite fixing the issue with the version change in the tsconfig
, PhpStorm 2016.3.2 continues to show a type hint error with the message:
TS2339: Property 'includes' does not exist on type 'string[]'.
If there is a way to make PhpStorm recognize that the use of includes()
is valid, that would be greatly appreciated.