{"id":3758,"date":"2020-05-20T16:20:11","date_gmt":"2020-05-20T16:20:11","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=3758"},"modified":"2020-05-20T16:20:11","modified_gmt":"2020-05-20T16:20:11","slug":"casting-object-types","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/casting-object-types\/","title":{"rendered":"Casting Object Types"},"content":{"rendered":"<p>While doing we need to let know Typescript how the datatypes are defined.The definition files are available in internet and it should be added to the script folder while doing the casting<\/p>\n<p>Suppose I am doing a casting <strong>HTMLElement <\/strong>while accessing DOMto <strong>HTMLInputElement <\/strong> i should add lib.d.ts which contains the definition for DOM elements.<\/p>\n<p>In the below code <em>document.getElementById(&#8216;Name&#8217;)<\/em> returns HTMLElement which is least specific compared to HTMLInputElement.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar name = &lt;HTMLInputElement&gt;document.getElementById('Name');\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>While doing we need to let know Typescript how the datatypes are defined.The definition files are available in internet and it should be added to the script folder while doing the casting Suppose I am doing a casting HTMLElement while accessing DOMto HTMLInputElement i should add lib.d.ts which contains the definition for DOM elements. In&hellip; <a href=\"https:\/\/codethataint.com\/blog\/casting-object-types\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-3758","post","type-post","status-publish","format-standard","hentry","category-casting"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=3758"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3758\/revisions"}],"predecessor-version":[{"id":3759,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3758\/revisions\/3759"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=3758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=3758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=3758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}