{"id":502,"date":"2022-11-03T20:39:23","date_gmt":"2022-11-03T12:39:23","guid":{"rendered":"https:\/\/islandtropicaman.com\/wp\/?p=502"},"modified":"2022-11-03T20:59:14","modified_gmt":"2022-11-03T12:59:14","slug":"create-typescript-interface","status":"publish","type":"post","link":"https:\/\/islandtropicaman.com\/wp\/2022\/11\/03\/create-typescript-interface\/","title":{"rendered":"Create TypeScript Interface"},"content":{"rendered":"<p>The following lines of code will create an interface in TypeScript:-<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\ninterface laptop {\r\n    brand : string;\r\n    user : string;\r\n    year : number;\r\n}\r\n<\/pre>\n<p>As you can see, the interface will declare the type of each element within it!<\/p>\n<p>The following lines of code will create an object based on the above interface.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nlet laptop1 : laptop = {\r\n    brand : &quot;Dell&quot;,\r\n    user : &quot;localhost&quot;,\r\n    year : 2022\r\n}\r\n<\/pre>\n<p>Once the interface has been declared you can use it just like the primitive types but you do need to declare every element within that interface through an object of that interface type with a true value.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following lines of code will create an interface in TypeScript:- interface laptop { brand : string; user : string; year : number; } As you can see, the interface will declare the type of each element within it! The following lines of code will create an object based on the above interface. let laptop1&#8230;<\/p>\n<p class=\"more-link-wrap\"><a href=\"https:\/\/islandtropicaman.com\/wp\/2022\/11\/03\/create-typescript-interface\/\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &ldquo;Create TypeScript Interface&rdquo;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[149,40],"class_list":["post-502","post","type-post","status-publish","format-standard","hentry","category-type-script","tag-interface","tag-typescript"],"blog_post_layout_featured_media_urls":{"thumbnail":"","full":""},"categories_names":{"38":{"name":"Type-Script","link":"https:\/\/islandtropicaman.com\/wp\/category\/type-script\/"}},"tags_names":{"149":{"name":"interface","link":"https:\/\/islandtropicaman.com\/wp\/tag\/interface\/"},"40":{"name":"typescript","link":"https:\/\/islandtropicaman.com\/wp\/tag\/typescript\/"}},"comments_number":"0","_links":{"self":[{"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/posts\/502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/comments?post=502"}],"version-history":[{"count":3,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/posts\/502\/revisions"}],"predecessor-version":[{"id":505,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/posts\/502\/revisions\/505"}],"wp:attachment":[{"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/media?parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/categories?post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/islandtropicaman.com\/wp\/wp-json\/wp\/v2\/tags?post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}