{"id":337098,"date":"2022-08-16T09:00:26","date_gmt":"2022-08-16T09:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337098"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337098","title":{"rendered":"<span>\u0417\u0430\u043c\u0435\u0442\u043a\u0430 \u043e Mapped Types \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e TypeScript<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 2 \u0441\u0442\u0430\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/javascript.plainenglish.io\/using-typescript-mapped-types-like-a-pro-be10aef5511a\">Use TypeScript Mapped Types Like a Pro<\/a> \u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 (mapped types) <code>TypeScript<\/code>;<\/li>\n<li><a href=\"https:\/\/obaranovskyi.medium.com\/10-typescript-features-you-might-not-be-using-yet-or-didnt-understand-d1f28888ea45\">10 TypeScript features you might not be using yet or didn&#8217;t understand<\/a> \u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e <code>TS<\/code>.<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"svyazannye-tipy\">\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u0432\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b <code>Partial<\/code>, <code>Required<\/code>, <code>Readonly<\/code> \u0438 <code>Pick<\/code>?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/7f\/-2\/_k\/7f-2_k31dqnahxozjntuthgpbtc.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/7f\/-2\/_k\/7f-2_k31dqnahxozjntuthgpbtc.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b?<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0438\u043f <code>User<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type User = {   name: string   password: string   address: string   phone: string }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0435\u0431\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f <code>PartialUser<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type PartialUser = {   name?: string   password?: string   address?: string   phone?: string }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0431\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f <code>ReadonlyUser<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type ReadonlyUser = {   readonly name: string   readonly password: string   readonly address: string   readonly phone: string }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043a\u043e\u0434\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/hc\/vq\/uw\/hcvquwn7fts7llojkvzgc7kakzg.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/hc\/vq\/uw\/hcvquwn7fts7llojkvzgc7kakzg.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e? \u041e\u0442\u0432\u0435\u0442 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 (generic types), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pk\/kz\/ed\/pkkzedppalge0mugmoezn7fw6_g.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pk\/kz\/ed\/pkkzedppalge0mugmoezn7fw6_g.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/s2\/ew\/ay\/s2ewaypt-t4bsjrwiyko-c3blre.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/s2\/ew\/ay\/s2ewaypt-t4bsjrwiyko-c3blre.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><code>P in K<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>for..in<\/code> \u0432 <code>JavaScript<\/code>, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u0432\u0441\u0435\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u0442\u0438\u043f\u0430 <code>K<\/code>. \u0422\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>T<\/code> \u2014 \u044d\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f, \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f <code>TS<\/code>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d-\/nm\/wc\/d-nmwcg237_lvj6bqf_30u0bhts.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/d-\/nm\/wc\/d-nmwcg237_lvj6bqf_30u0bhts.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>readonly<\/code> \u0438 <code>?<\/code>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 <code>+<\/code> \u0438 <code>-<\/code>. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">{ [ P in K ] : T } { [ P in K ] ?: T } { [ P in K ] -?: T } { readonly [ P in K ] : T } { readonly [ P in K ] ?: T } { -readonly [ P in K ] ?: T }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/qe\/xe\/r6\/qexer6fgk4n1ocnv7c20inbik1y.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/qe\/xe\/r6\/qexer6fgk4n1ocnv7c20inbik1y.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0438\u043f <code>PartialUser<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type MyPartial&lt;T> = {   [P in keyof T]?: T[P] }  type PartialUser = MyPartial&lt;User><\/code><\/pre>\n<p>  <\/p>\n<p><code>MyPartial<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 <code>User<\/code> \u0438 <code>PartialUser<\/code>. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>keyof<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0442\u0438\u043f\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (union type). \u0422\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>P<\/code> \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. <code>T[P]<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <code>MyPartial<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/vj\/l1\/z1\/vjl1z1gfvglzxjtkad6aodeeg_k.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/vj\/l1\/z1\/vjl1z1gfvglzxjtkad6aodeeg_k.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><code>TS 4.1<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>as<\/code>. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type MappedTypeWithNewKeys&lt;T> = {     [K in keyof T as NewKeyType]: T[K]     \/\/            ^^^^^^^^^^^^^ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>NewKeyType<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f <code>string | number | symbol<\/code>. <code>as<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type Getters&lt;T> = {   [K in keyof T as `get${Capitalize&lt;string &amp; K>}`]: () => T[K] }  interface Person {     name: string     age: number     location: string }  type LazyPerson = Getters&lt;Person> \/\/ { \/\/   getName: () => string \/\/   getAge: () => number \/\/   getLocation: () => string \/\/ }<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/hv\/lw\/cg\/hvlwcg2qb7zhdkp8plwumgcvgvu.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/hv\/lw\/cg\/hvlwcg2qb7zhdkp8plwumgcvgvu.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0438\u043f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 <code>keyof T<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0438\u043f <code>symbol<\/code>, \u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f <code>Capitalize<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0431\u044b\u043b \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c <code>string<\/code>, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>&amp;<\/code> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 <code>never<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e 'kind' type RemoveKindField&lt;T> = {     [K in keyof T as Exclude&lt;K, 'kind'>]: T[K] }  interface Circle {     kind: 'circle'     radius: number }  type KindlessCircle = RemoveKindField&lt;Circle> \/\/   type KindlessCircle = { \/\/       radius: number \/\/   }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"tip-unknown\">\u0422\u0438\u043f <code>unknown<\/code><\/h2>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>unknown<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 (\u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432) \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0442\u0438\u043f\u0430 <code>any<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043e\u0431\u0449\u0435\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 <code>any<\/code> \u0438 <code>unknown<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let anyValue: any = 'any value' anyValue = true anyValue = 123 console.log(anyValue) \/\/ 123  let unknownValue: unknown unknownValue = 'unknown value' unknownValue = true unknownValue = 123 console.log(unknownValue) \/\/ 123<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>any<\/code>, <code>unknown<\/code> \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c &#171;\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c\u0438&#187; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const anyValue: any = 'any value' console.log(anyValue.add())<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const anyValue: any = true anyValue.typescript.will.not.complain.about.this.method()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430).<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>any<\/code> \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443: &#171;\u041d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u2014 \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e&#187;. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <code>TS<\/code>, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0430. \u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>unknown<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438). \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u043d\u043e\u0433\u0438\u0435 <code>IDE<\/code> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u043f.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let unknownValue: unknown  unknownValue = 'unknown value' unknownValue.toString() \/\/ \u041e\u0448\u0438\u0431\u043a\u0430: Object is of type 'unknown'.  unknownValue = 100 const value = unknownValue + 10 \/\/ \u041e\u0448\u0438\u0431\u043a\u0430: Object is of type 'unknown'.  unknownValue = console unknownValue.log('test') \/\/ \u041e\u0448\u0438\u0431\u043a\u0430: Object is of type 'unknown'.<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0441\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 (type narrowing). \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 (type assertion):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let unknownValue: unknown  unknownValue = function () {}  ;(unknownValue as Function).call(null)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0435\u0434\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044f \u0442\u0438\u043f\u0430 (type guard):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let unknownValue: unknown  unknownValue = 'unknown value'  if (typeof unknownValue === 'string') unknownValue.toString()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044f \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let unknownValue: unknown  type User = { username: string }  function isUser(maybeUser: any): maybeUser is User {   return 'username' in maybeUser }  unknownValue = { username: 'John' }  if (isUser(unknownValue)) {   console.log(unknownValue.username) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f (assertion function):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let unknownValue: unknown  unknownValue = 123  function isNumber(value: unknown): asserts value is number {   if (typeof value !== 'number') throw Error('\u041f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c!') }  isNumber(unknownValue)  unknownValue.toFixed()<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"indeksirovannyy-tip-dostupa-tip-poiska\">\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0442\u0438\u043f \u043f\u043e\u0438\u0441\u043a\u0430)<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (indexed access type) \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0442\u0438\u043f\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type User = {   id: number   username: string   email: string   address: {     city: string     state: string     country: string     postalCode: number   }   addons: { name: string, id: number }[] }  type Id = User['id'] \/\/ number type Session = User['address'] \/\/ { \/\/   city: string \/\/   state: string \/\/   country: string \/\/   postalCode: string \/\/ } type Street = User['address']['state'] \/\/ string type Addons = User['addons'][number] \/\/ { \/\/   name: string \/\/   id: number \/\/ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b <code>Id<\/code>, <code>Session<\/code>, <code>Street<\/code> \u0438 <code>Addons<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function printAddress(address: User['address']): void {   console.log(`     city: ${address.city},     state: ${address.state},     country: ${address.country},     postalCode: ${address.postalCode}   `) }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"klyuchevoe-slovo-infer\">\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>infer<\/code><\/h2>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>infer<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const User = {   id: 123,   username: 'John',   email: 'john@mail.com',   addons: [     { name: 'First addon', id: 1 },     { name: 'Second addon', id: 2 }   ] }  type UnpackArray&lt;T> = T extends (infer R)[] ? R : T  type AddonType = UnpackArray&lt;typeof User.addons> \/\/ { name: string, id: number }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>addon<\/code> \u0432\u044b\u0434\u0435\u043b\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f.<\/p>\n<p>  <\/p>\n<h2 id=\"funkcii-utverzhdeniya\">\u0424\u0443\u043d\u043a\u0446\u0438\u0438-\u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435. \u0422\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f &#171;\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438-\u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438&#187; (assertion functions):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function assertIsString(value: unknown): asserts value is string {   if (typeof value !== 'string') throw Error('\u041f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439!') }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type User = {   id: number   username: string   email: string   address: {     city: string     state: string     country: string     postalCode: number   } }  function assertIsObject(obj: unknown, errorMessage: string = '\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442!'): asserts obj is object {   if(typeof obj !== 'object' || obj === null) throw new Error(errorMessage) }  function assertIsAddress(address: unknown): asserts address is User['address'] {   const errorMessage = '\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b \u0430\u0434\u0440\u0435\u0441!'   assertIsObject(address, errorMessage)    if(     !('city' in address) ||     !('state' in address) ||     !('country' in address) ||     !('postalCode' in address)   ) throw new Error(errorMessage) }  function assertIsUser(user: unknown): asserts user is User {   const errorMessage = '\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c!'   assertIsObject(user, errorMessage)    if(     !('id' in user) ||     !('username' in user) ||     !('email' in user)   ) throw new Error(errorMessage)    assertIsAddress((user as User).address) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class UserWebService {   static getUser = (id: number): User | unknown => undefined }  const user = UserWebService.getUser(123)  assertIsUser(user) \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \"\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c\", \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  user.address.postalCode \/\/ \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e `user` - \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"tip-never\">\u0422\u0438\u043f <code>never<\/code><\/h2>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>never<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function plus1If1(value: number): number | never {   if(value === 1) return value + 1    throw new Error('\u041e\u0448\u0438\u0431\u043a\u0430!') }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u0440\u043e\u043c\u0438\u0441\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const promise = (value: number) => new Promise&lt;number | never>((resolve, reject) => {   if(value === 1) resolve(1 + value)    reject(new Error('\u041e\u0448\u0438\u0431\u043a\u0430!')) })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function infiniteLoop(): never {   while (true) {     \/\/ ...   } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>never<\/code> \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c &#171;\u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445&#187; \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function valueCheck(value: string | number) {   if (typeof value === \"string\") {     \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439   } else if (typeof value === \"number\") {     \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c   } else {     \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f `never`   } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"utverzhdenie-const\">\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 <code>const<\/code><\/h2>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>const<\/code> \u043f\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (literal expressions) \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0442\u0438\u043f\u044b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0438\u043f <code>\u043f\u0440\u0438\u0432\u0435\u0442<\/code> \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 <code>string<\/code>);<\/li>\n<li>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f (<code>readonly<\/code>);<\/li>\n<li>\u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438 (tuples).<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const email = 'john@mail.com' \/\/ john@mail.com const phones = [89876543210, 89123456780] \/\/ number[] const session = { id: 123, name: 'qwerty123456' } \/\/ { \/\/     id: number \/\/     name: string \/\/ }  const username = 'John' as const \/\/ John const roles = [ 'read', 'write'] as const \/\/ readonly [\"read\", \"write\"] const address = { street: 'Tokyo', country: 'Japan' } as const \/\/ { \/\/     readonly street: \"Tokyo\" \/\/     readonly country: \"Japan\" \/\/ }  const user = {   email,   phones,   session,   username,   roles,   address } as const \/\/ { \/\/     readonly email: \"john@mail.com\" \/\/     readonly phones: number[] \/\/     readonly session: { \/\/       id: number \/\/       name: string \/\/     } \/\/     readonly username: \"John\" \/\/     readonly roles: readonly [\"read\", \"write\"] \/\/     readonly address: { \/\/         readonly street: \"Tokyo\" \/\/         readonly country: \"Japan\" \/\/     } \/\/ }  \/\/ \u0421 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c `const` \/\/ user.email = 'jane@mail.com' \/\/ \u041e\u0448\u0438\u0431\u043a\u0430 \/\/ user.phones = [] \/\/ \u041e\u0448\u0438\u0431\u043a\u0430 user.phones.push(89087654312) \/\/ user.session = { name: 'test4321', id: 124 } \/\/ \u041e\u0448\u0438\u0431\u043a\u0430 user.session.name = 'test4321'  \/\/ \u0421 \"\u0432\u043d\u0435\u0448\u043d\u0438\u043c\" \u0438 \"\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c\" \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 `const` \/\/ user.username = 'Jane' \/\/ \u041e\u0448\u0438\u0431\u043a\u0430 \/\/ user.roles.push('ReadAndWrite') \/\/ \u041e\u0448\u0438\u0431\u043a\u0430 \/\/ user.address.city = 'Osaka' \/\/ \u041e\u0448\u0438\u0431\u043a\u0430<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 <code>const<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const roles = ['read', 'write', 'readAndWrite'] as const  type Roles = typeof roles[number] \/\/ \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \/\/ type Roles = \"read\" | \"write\" | \"readAndWrite\"  type RolesInCapital = Capitalize&lt;typeof roles[number]> \/\/ \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \/\/ type RolesInCapital = \"Read\" | \"Write\" | \"ReadAndWrite\"<\/code><\/pre>\n<p>  <\/p>\n<p><code>[number]<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 <code>TS<\/code> \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>roles<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"klyuchevoe-slovo-override\">\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>override<\/code><\/h2>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>override<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <code>TS 4.3<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Employee {   doWork() {     console.log('\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e')   } }  class Developer extends Employee {   override doWork() {     console.log('\u042f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u044e')   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 &#171;\u0444\u0438\u0447\u0443&#187; \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">{   \"compilerOptions\": {     \"noImplicitOverride\": true   } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"blok-static\">\u0411\u043b\u043e\u043a <code>static<\/code><\/h2>\n<p>  <\/p>\n<p><code>static<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <code>TS 4.4<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function userCount() {   return 10 }  class User {   id = 0   static count: number = 0    constructor(     public username: string,     public age: number   ) {     this.id = ++User.count   }    static {     User.count += userCount()   } }  console.log(User.count) \/\/ 10 new User('John', 32) new User('Jane', 23) console.log(User.count) \/\/ 12<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"staticheskie-indeksy-i-indeksy-ekzemplyarov\">\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (index signature) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0447\u0435\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u0432 \u0442\u0438\u043f\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {   username: string   age: number    constructor(username: string,age: number) {     this.username = username     this.age = age   }    [propName: string]: string | number }  const user = new User('John', 23) user['phone'] = '+79876543210'  const something = user['something']<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {   username: string   age: number    constructor(username: string,age: number) {     this.username = username     this.age = age   }    static [propName: string]: string | number }  User['userCount'] = 0  const something = User['something']<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0435\u043c \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u043d\u0435 \u0437\u0440\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/vds-promo-8-rub?utm_source=habr&amp;utm_medium=blog_1560_476&amp;utm_campaign=habr&amp;utm_content=1560_476\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/co\/e2\/kh\/coe2kha8u8_pypip-2k3wk3ppa0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/co\/e2\/kh\/coe2kha8u8_pypip-2k3wk3ppa0.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/682748\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/682748\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 2 \u0441\u0442\u0430\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/javascript.plainenglish.io\/using-typescript-mapped-types-like-a-pro-be10aef5511a\">Use TypeScript Mapped Types Like a Pro<\/a> \u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 (mapped types) <code>TypeScript<\/code>;<\/li>\n<li><a href=\"https:\/\/obaranovskyi.medium.com\/10-typescript-features-you-might-not-be-using-yet-or-didnt-understand-d1f28888ea45\">10 TypeScript features you might not be using yet or didn&#8217;t understand<\/a> \u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e <code>TS<\/code>.<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-337098","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337098"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337098\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}