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 />
<input id="submit" type="button" value="Submit" />
</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.
source
share