{"id":1941,"date":"2019-06-12T18:35:53","date_gmt":"2019-06-12T16:35:53","guid":{"rendered":"https:\/\/www.thecodecampus.de\/blog\/?p=1941"},"modified":"2025-04-22T10:54:02","modified_gmt":"2025-04-22T08:54:02","slug":"pitfall-using-object-keys-with-typescript-classes","status":"publish","type":"post","link":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/","title":{"rendered":"Pitfall using Object.keys() with Typescript classes"},"content":{"rendered":"<p>In this blog article I would like to describe a stumbling block I stumbled across in my work. TypeScript (TS) is a very good way to increase productivity. The compiler and type system fix many software bugs before they occur. Also the possibility to translate into different versions of ECMAScript (ES) is a useful feature of the TS compiler.<\/p>\n<p>In my TS project there is a help function that should determine the names of all methods of a class and its superclasses. This function worked fine for a target of ES version 5. This function always produced an empty output after I changed the target version to ES 2015.<\/p>\n<p><a href=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2573 size-full\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp\" alt=\"\" width=\"750\" height=\"303\" \/><\/a><\/p>\n<p>Let&#8217;s take a brief look at how exactly methods of a class are stored in ES. If we use ES classes then the methods of a class will be attached to the prototype of the class.<\/p>\n<p>The original TS code:<\/p>\n<pre class=\"lang:js decode:true\" title=\"functions.ts\">function functionNamesShallowWithObjectKeys(object: any): string[] {\r\n  if (object == null) {\r\n    return [];\r\n  }\r\n  return Object.keys(object).filter(key =&gt; {\r\n    return (\r\n      typeof object[key] === \"function\" &amp;&amp;\r\n      excludeMethodNames.indexOf(key) === -1\r\n    );\r\n  });\r\n}\r\n\r\nfunction functionNamesDeep(object: any): string[] {\r\n  let fnMembers: string[] = functionNamesShallowWithObjectKeys(object);\r\n\r\n  const proto = Object.getPrototypeOf(object);\r\n  if (proto !== null &amp;&amp; proto !== Object.prototype) {\r\n    fnMembers = [...fnMembers, ...functionNamesShallowWithObjectKeys(proto)];\r\n  }\r\n  return fnMembers;\r\n}<\/pre>\n<p><a href=\"https:\/\/www.thecodecampus.de\/schulungen\/angular\" style=\"display: inline-block;\">\n<picture><source srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2025\/04\/angular-schulungen_anne_WP_big.png\" media=\"(min-width: 1024px)\"><source srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2025\/04\/angular-schulungen_anne_WP_medium.png\" media=\"(min-width: 600px)\"><img decoding=\"async\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2025\/04\/angular-schulungen_anne_WP_small.png\" alt=\"Angular Schulungen\" class=\"alignnone size-full wp-image-38\">\n<\/picture>\n<\/a><\/p>\n<p>In the first step I compared the code of the function that was generated for both target ES versions. To my surprise it was identical except the exchange of the spread operator.<\/p>\n<pre class=\"marking:true lang:js mark:14 decode:true\" title=\"es5 version of functions.ts\">function functionNamesShallowWithObjectKeys(object) {\r\n    if (object == null) {\r\n        return [];\r\n    }\r\n    return Object.keys(object).filter(function (key) {\r\n        return (typeof object[key] === \"function\" &amp;&amp;\r\n            excludeMethodNames.indexOf(key) === -1);\r\n    });\r\n}\r\nfunction functionNamesDeep(object) {\r\n    var fnMembers = functionNamesShallowWithObjectKeys(object);\r\n    var proto = Object.getPrototypeOf(object);\r\n    if (proto !== null &amp;&amp; proto !== Object.prototype) {\r\n        fnMembers = fnMembers.concat(functionNamesShallowWithObjectKeys(proto));\r\n    }\r\n    return fnMembers;\r\n}<\/pre>\n<pre class=\"marking:true lang:js mark:19 decode:true\" title=\"Es2015 version of functions.ts\">function functionNamesShallowWithObjectKeys(object) {\r\n    if (object == null) {\r\n        return [];\r\n    }\r\n    return Object.keys(object).filter(key =&gt; {\r\n        return (typeof object[key] === \"function\" &amp;&amp;\r\n            excludeMethodNames.indexOf(key) === -1);\r\n    });\r\n}\r\nfunction functionNamesDeep(object, useObjectKeys = false) {\r\n    let fnMembers = useObjectKeys\r\n        ? functionNamesShallowWithObjectKeys(object)\r\n        : functionNamesShallow(object);\r\n    const proto = Object.getPrototypeOf(object);\r\n    if (proto !== null &amp;&amp; proto !== Object.prototype) {\r\n        const functionsOfProto = useObjectKeys\r\n            ? functionNamesShallowWithObjectKeys(proto)\r\n            : functionNamesShallow(proto);\r\n        fnMembers = [...fnMembers, ...functionsOfProto];\r\n    }\r\n    return fnMembers;\r\n}<\/pre>\n<p>So how could it be that the conversion of the target version caused the code to stop working? The answer is half in the ES standard and half in the original implementation.<\/p>\n<p>In the faulty implementation Object.Keys() was used. This iterates over all enumerable properties of an object. If the code is translated by TS to ES5, the methods are translated into functions. These are then saved as properties to the prototype of the generated constructor function. This write access creates a property that is enumerable.<\/p>\n<pre class=\"lang:js decode:true \" title=\"Class Foo in ES5\">var Foo = \/** @class *\/ (function () {\r\n    function Foo() {\r\n        this.counter = 0;\r\n    }\r\n    Foo.prototype.increment = function () {\r\n        return ++this.counter;\r\n    };\r\n    Foo.prototype.decrement = function () {\r\n        return --this.counter;\r\n    };\r\n    return Foo;\r\n}());<\/pre>\n<p>Unfortunately, according to the ES standard, the methods of a class are stored on their prototype, but they are not enumerable. Consequently Object.keys() cannot iterate over these properties. Fixing the error is quite easy armed with this knowledge. Instead of Object.keys() we work with Object.getOwnPropertyNames() or Object.getOwnPropertyDescriptors().<\/p>\n<pre class=\"lang:js decode:true\">function functionNamesShallow(object: any): string[] {\r\n  if (object == null) {\r\n    return [];\r\n  }\r\n  return Object.getOwnPropertyNames(object).filter(key =&gt; {\r\n    return (\r\n      typeof Object.getOwnPropertyDescriptor(object, key).value ===\r\n        \"function\" &amp;&amp; excludeMethodNames.indexOf(key) === -1\r\n    );\r\n  });\r\n}\r\n\r\nfunction functionNamesDeep(object: any): string[] {\r\n  let fnMembers: string[] = functionNamesShallow(object);\r\n\r\n  const proto = Object.getPrototypeOf(object);\r\n  if (proto !== null &amp;&amp; proto !== Object.prototype) {\r\n    fnMembers = [...fnMembers, ...functionNamesDeep(proto)];\r\n  }\r\n  return fnMembers;\r\n}<\/pre>\n<h2>Conclusion<\/h2>\n<p>So you have to be aware that <span class=\"lang:js decode:true crayon-inline \">Object.keys()<\/span>\u00a0 is not suitable to iterate over properties of classes. Use <span class=\"lang:js decode:true crayon-inline \">Object.getOwnPropertyNames()<\/span>\u00a0 or <span class=\"lang:js decode:true crayon-inline \">Object.getOwnPropertyDescriptors() instead<\/span>\u00a0. I hope I could help you to avoid this pitfall.<\/p>\n<p>You can find the complete code on Github <a href=\"https:\/\/github.com\/sengmann\/object-keys-bug\">https:\/\/github.com\/sengmann\/object-keys-bug<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog article I would like to describe a stumbling block I stumbled across in my work. TypeScript (TS) is a very good way to increase productivity. The compiler and type system fix many software bugs before they occur. Also the possibility to translate into different versions of ECMAScript (ES) is a useful feature [&#8230;]<br \/><a class=\"meta-big\" href=\"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/\"> READ MORE<\/a><\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,98,60],"tags":[],"class_list":["post-1941","post","type-post","status-publish","format-standard","hentry","category-javascript","category-node-js","category-typescript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pitfall using Object.keys() with Typescript classes - Web Development Blog<\/title>\n<meta name=\"description\" content=\"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pitfall using Object.keys() with Typescript classes - Web Development Blog\" \/>\n<meta property=\"og:description\" content=\"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development tips and tricks - theCodeCampus Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-12T16:35:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-22T08:54:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"303\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sascha Engmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sascha Engmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/\"},\"author\":{\"name\":\"Sascha Engmann\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/34862192d5819d0b5576748a6388cf96\"},\"headline\":\"Pitfall using Object.keys() with Typescript classes\",\"datePublished\":\"2019-06-12T16:35:53+00:00\",\"dateModified\":\"2025-04-22T08:54:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/\"},\"wordCount\":374,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/overview-3.webp\",\"articleSection\":[\"JavaScript\",\"Node.js\",\"TypeScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/\",\"name\":\"Pitfall using Object.keys() with Typescript classes - Web Development Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/overview-3.webp\",\"datePublished\":\"2019-06-12T16:35:53+00:00\",\"dateModified\":\"2025-04-22T08:54:02+00:00\",\"description\":\"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/overview-3.webp\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/overview-3.webp\",\"width\":750,\"height\":303},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/pitfall-using-object-keys-with-typescript-classes\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pitfall using Object.keys() with Typescript classes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"name\":\"Web Development tips and tricks - theCodeCampus Blog\",\"description\":\"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\",\"name\":\"theCodeCampus\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"width\":156,\"height\":156,\"caption\":\"theCodeCampus\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/34862192d5819d0b5576748a6388cf96\",\"name\":\"Sascha Engmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/sascha-engmann-tcc-author-96x96.webp\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/sascha-engmann-tcc-author-96x96.webp\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/sascha-engmann-tcc-author-96x96.webp\",\"caption\":\"Sascha Engmann\"},\"description\":\"Sascha is a trainer with heart and soul. His spectrum ranges from Java to database development and web technologies. In recent years, he has immersed himself in the world of Angular. He is happy to pass on his theoretical and practical knowledge to beginners, but of course also to curious experienced developers.\",\"sameAs\":[\"https:\\\/\\\/thecodecampus.de\\\/ueber-uns\\\/trainer\\\/sascha-engmann\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sascha-engmann-37065b1a4\\\/\"],\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/author\\\/sengmann\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pitfall using Object.keys() with Typescript classes - Web Development Blog","description":"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/","og_locale":"en_US","og_type":"article","og_title":"Pitfall using Object.keys() with Typescript classes - Web Development Blog","og_description":"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!","og_url":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/","og_site_name":"Web Development tips and tricks - theCodeCampus Blog","article_published_time":"2019-06-12T16:35:53+00:00","article_modified_time":"2025-04-22T08:54:02+00:00","og_image":[{"width":750,"height":303,"url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp","type":"image\/webp"}],"author":"Sascha Engmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sascha Engmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#article","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/"},"author":{"name":"Sascha Engmann","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/34862192d5819d0b5576748a6388cf96"},"headline":"Pitfall using Object.keys() with Typescript classes","datePublished":"2019-06-12T16:35:53+00:00","dateModified":"2025-04-22T08:54:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/"},"wordCount":374,"commentCount":0,"publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#primaryimage"},"thumbnailUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp","articleSection":["JavaScript","Node.js","TypeScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/","url":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/","name":"Pitfall using Object.keys() with Typescript classes - Web Development Blog","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#primaryimage"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#primaryimage"},"thumbnailUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp","datePublished":"2019-06-12T16:35:53+00:00","dateModified":"2025-04-22T08:54:02+00:00","description":"Avoid TypeScript pitfalls! Uncover Object.keys challenges with classes. Navigate solutions, enhance code reliability. Level up TypeScript now!","breadcrumb":{"@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#primaryimage","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/06\/overview-3.webp","width":750,"height":303},{"@type":"BreadcrumbList","@id":"https:\/\/www.thecodecampus.de\/blog\/pitfall-using-object-keys-with-typescript-classes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.thecodecampus.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Pitfall using Object.keys() with Typescript classes"}]},{"@type":"WebSite","@id":"https:\/\/www.thecodecampus.de\/blog\/#website","url":"https:\/\/www.thecodecampus.de\/blog\/","name":"Web Development tips and tricks - theCodeCampus Blog","description":"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.","publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.thecodecampus.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.thecodecampus.de\/blog\/#organization","name":"theCodeCampus","url":"https:\/\/www.thecodecampus.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","width":156,"height":156,"caption":"theCodeCampus"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/34862192d5819d0b5576748a6388cf96","name":"Sascha Engmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/11\/sascha-engmann-tcc-author-96x96.webp","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/11\/sascha-engmann-tcc-author-96x96.webp","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/11\/sascha-engmann-tcc-author-96x96.webp","caption":"Sascha Engmann"},"description":"Sascha is a trainer with heart and soul. His spectrum ranges from Java to database development and web technologies. In recent years, he has immersed himself in the world of Angular. He is happy to pass on his theoretical and practical knowledge to beginners, but of course also to curious experienced developers.","sameAs":["https:\/\/thecodecampus.de\/ueber-uns\/trainer\/sascha-engmann","https:\/\/www.linkedin.com\/in\/sascha-engmann-37065b1a4\/"],"url":"https:\/\/www.thecodecampus.de\/blog\/author\/sengmann\/"}]}},"_links":{"self":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/comments?post=1941"}],"version-history":[{"count":16,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1941\/revisions"}],"predecessor-version":[{"id":3467,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1941\/revisions\/3467"}],"wp:attachment":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/media?parent=1941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/categories?post=1941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/tags?post=1941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}