node.js - TS-2304 Error - can not find name 'Iterable' in TypeScript while importing "jquery" in ".ts" file -


i working on typescript version 2.4 using visual studio code editor. installed jquery npm using following command:

npm install --save @types/jquery 

then downloaded source code of jquery module github.

the code of registrationpage.ts file follows:

import * $ '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 index.html 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 compile code on cmd , following error:

error ts2304 : cannot find name iterable

please suggest appropriate solution.

the configuration of tsconfig.json correct. when target set es5 , libraries : es2015,es2015-iterable included iterable supported. point when compile .ts file command tsc "filename" "tsconfig.json" ignored compiler. also, while working external modules, need include following js files support module loading:

https://unpkg.com/core-js/client/shim.min.js">  https://unpkg.com/systemjs@0.19.39/dist/system.src.js 

lastly, compile file command

**tsc -p .** 

this command not ignore tsconfig.json file.

hope helps.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -