{"id":1833,"date":"2023-12-01T05:00:00","date_gmt":"2023-12-01T13:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1833"},"modified":"2023-11-30T16:59:05","modified_gmt":"2023-12-01T00:59:05","slug":"make-types-from-json-samples","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/make-types-from-json-samples\/","title":{"rendered":"Make types from JSON samples"},"content":{"rendered":"\n<p>First, a <strong>quick announcement<\/strong>: I&#8217;m running a donation-based online Angular Signals Workshop on December 14th and January 18th. If you&#8217;re interested, feel free to <a href=\"https:\/\/forms.gle\/b8SKcLK1EscHgN8o9\" target=\"_blank\" rel=\"noopener\" title=\"\">show your interest here<\/a>, and remember that you don&#8217;t have to pay anything if you don&#8217;t want to or can&#8217;t.<\/p>\n\n\n\n<p>Earlier this year, I shared <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/how-to-generate-type-definitions-for-typescript\/\" target=\"_blank\" rel=\"noopener\" title=\"\">how to generate type definitions for Typescript<\/a> using <strong>json2ts<\/strong>, but that website has disappeared. A suggested superior alternative is <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/how-to-generate-dtos-for-data-objects\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Quicktype<\/a>, which can also create DTOs and has several config options.<\/p>\n\n\n\n<p>Recently, I heard about another option called <a href=\"https:\/\/jvilk.com\/MakeTypes\/\" target=\"_blank\" rel=\"noopener\" title=\"\">MakeTypes<\/a>. It&#8217;s as simple as the two previous tools, and it can also be downloaded via npm to be part of your local development process if that&#8217;s what you want:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"663\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/11\/image-41-1024x663.png\" alt=\"\" class=\"wp-image-1834\" style=\"width:634px;height:auto\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/11\/image-41-1024x663.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/11\/image-41-300x194.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/11\/image-41-768x497.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/11\/image-41.png 1196w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Again, all you need to do is copy-paste your sample JSON and get instant Typescript interfaces (or proxy classes) to use in your project. And if you don&#8217;t want to use a website to create your types, head to the <a href=\"https:\/\/www.npmjs.com\/package\/maketypes\" target=\"_blank\" rel=\"noopener\" title=\"\">NPM page<\/a> to download the tool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, a quick announcement: I&#8217;m running a donation-based online Angular Signals Workshop on December 14th and January 18th. If you&#8217;re interested, feel free to show your interest here, and remember that you don&#8217;t have to pay anything if you don&#8217;t want to or can&#8217;t. Earlier this year, I shared how to generate type definitions for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,17,3],"tags":[],"class_list":["post-1833","post","type-post","status-publish","format-standard","hentry","category-angular","category-tools","category-typescript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1833"}],"version-history":[{"count":2,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1833\/revisions"}],"predecessor-version":[{"id":1836,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1833\/revisions\/1836"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}