Error TS-2304 - Cannot find the name "Iterable" in TypeScript when importing "jquery" into the file .ts

I am working on TypeScript version 2.4 using Visual Studio Code as an editor. I installed jQuery with NPM using the following command:

npm install --save @types/jquery

Then I downloaded the source code jquery modulefrom GitHub .

The file code is registrationpage.tsas follows:

import * as $ from 'jquery';
class Registration_Page {
    txtuname: string;
    Registration() {
        $('#table').hide;
        this.txtuname = ( <HTMLTextAreaElement> (document.getElementById('txtusername'))).value;
    }
}
window.onload = () => {
    $('#table').show;
    var bttnLogin = document.getElementById('submit');
    var obj = new Registration_Page();
    bttnLogin.onclick = function () {
        obj.Registration();
    }
}

The code is index.htmlas follows:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="registrationpage.js"></script>

</head>
<body>
    <form id="form1">
    <div>
     <fieldset style="font-size: medium; color: #000000;">
        <legend style="background-color:#CCCCFF; font-size: larger;font-weight:bold">Registration Page in TypeScript</legend>
        <br />
        <b>UserName</b>
        <input id="txtusername" type="text" /><br />
        <br />

        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input id="submit" type="button" value="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;

    </fieldset>
    </div>
    <div id="table">
        <table>
            <tr>
                <th>UserName</th>

            </tr>
        </table>
    </div>
    </form>
</body>
</html>

tsconfig.json file:

{
    "compilerOptions": {
        "target": "es5",
        "noImplicitAny": true,
        "lib": [ "es2015", "dom" ]

    }

}

When I compile the code in CMD, I get the following error:

ERROR TS2304: Cannot find the name Iterable

Please suggest a suitable solution.

+4
source share
2 answers

tsconfig.json . ​​ ES5, : es2015,es2015-iterable , Iterable. , .ts tsc "filename", "tsconfig.json" . , js :

https://unpkg.com/core-js/client/shim.min.js">

https://unpkg.com/systemjs@0.19.39/dist/system.src.js

,

**tsc -p .**

tsconfig.json.

, .

+2

node.

npm i --save-dev @types/node

:

yarn add -D @types/node

+1

Source: https://habr.com/ru/post/1682493/


All Articles