{"id":324945,"date":"2021-06-15T15:00:46","date_gmt":"2021-06-15T15:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=324945"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=324945","title":{"rendered":"\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430 \u043f\u043e TypeScript. \u0427\u0430\u0441\u0442\u044c 6. \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ad\/rw\/w4\/adrww41gv8k_vuxeswr0-xkl57y.png\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/intro.html\"><code> &quot;\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e TypeScript<\/code>&quot;.<\/a>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/559902\/\">\u0427\u0430\u0441\u0442\u044c 1. \u041e\u0441\u043d\u043e\u0432\u044b<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/559976\/\">\u0427\u0430\u0441\u0442\u044c 2. \u0422\u0438\u043f\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/560594\/\">\u0427\u0430\u0441\u0442\u044c 3. \u0421\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/561470\/\">\u0427\u0430\u0441\u0442\u044c 4. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/562054\/\">\u0427\u0430\u0441\u0442\u044c 5. \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 <code>TS<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u043e\u0439 \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0438\u043b\u0438 \u043e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b (generics). \u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0442\u0438\u043f\u0430. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0443 \u043d\u0430\u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h1 id=\"dzheneriki\">\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/h1>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>identity<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity(arg: number): number {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f <code>any<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity(arg: any): any {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u043d\u0430\u0442\u044c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0438\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity&lt;Type&gt;(arg: Type): Type {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>Type<\/code> \u043a\u0430\u043a \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0431\u0449\u0438\u043c\u0438 (\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0432\u0441\u0435\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const output = identity&lt;string&gt;('myStr')    \/\/ let output: string<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u0442\u0438\u043f\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const output = identity('myStr')    \/\/ let output: string<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044f\u0432\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"rabota-s-peremennymi-tipa-v-dzhenerikah\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 \u0432 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u0445<\/h2>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0434\u043b\u0438\u043d\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <code>arg<\/code> \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c?<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function loggingIdentity&lt;Type&gt;(arg: Type): Type {  console.log(arg.length)  \/\/ Property 'length' does not exist on type 'Type'.  \/\/ \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 'length' \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0442\u0438\u043f\u0435 'Type'  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 (\u0430, \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u0441\u0435) \u0442\u0438\u043f, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>arg<\/code> \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>length<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c <code>Type<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function loggingIdentity&lt;Type&gt;(arg: Type[]): Type[] {  console.log(arg.length)  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>Type<\/code> \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>arg<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c <code>Type<\/code>, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 <code>Type<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function loggingIdentity&lt;Type&gt;(arg: Array&lt;Type&gt;): Array&lt;Type&gt; {  console.log(arg.length)  return arg }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"obschie-tipy\">\u041e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>  <\/p>\n<p>\u0422\u0438\u043f \u043e\u0431\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430) \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0442\u0438\u043f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity&lt;Type&gt;(arg: Type): Type {  return arg }  const myIdentity: &lt;Type&gt;(arg: Type) =&gt; Type = identity<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043e\u0431\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity&lt;Type&gt;(arg: Type): Type {  return arg }  const myIdentity: &lt;Input&gt;(arg: Input) =&gt; Input = identity<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity&lt;Type&gt;(arg: Type): Type {  return arg }  const myIdentity: { &lt;Type&gt;(arg: Type): Type } = identity<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">interface GenericIdentityFn {  &lt;Type&gt;(arg: Type): Type }  function identity&lt;Type&gt;(arg: Type): Type {  return arg }  const myIdentity: GenericIdentityFn = identity<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u0438\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">interface GenericIdentityFn&lt;Type&gt; {  (arg: Type): Type }  function identity&lt;Type&gt;(arg: Type): Type {  return arg }  const myIdentity: GenericIdentityFn&lt;number&gt; = identity<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u043e\u0431\u0449\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>, \u0447\u0442\u043e \u043e\u0431\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (enums) \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d (namespaces) \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"obschie-klassy\">\u041e\u0431\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0444\u043e\u0440\u043c\u0443, \u0447\u0442\u043e \u0438 \u043e\u0431\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class GenericNumber&lt;NumType&gt; {  zeroValue: NumType  add: (x: NumType, y: NumType) =&gt; NumType }  const myGenericNum = new GenericNumber&lt;number&gt;() myGenericNum.zeroValue = 0 myGenericNum.add = (x, y) =&gt; x + y<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043c\u044b \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u041c\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const stringNumeric = new GenericNumber&lt;string&gt;() stringNumeric.zeroValue = '' stringNumeric.add = (x, y) =&gt; x + y  console.log(stringNumeric.add(stringNumeric.zeroValue, 'test'))<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432: \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432. \u041e\u0431\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"ogranicheniya-dzhenerikov\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>loggingIdentity<\/code> \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>length<\/code> \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <code>arg<\/code>, \u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function loggingIdentity&lt;Type&gt;(arg: Type): Type {  console.log(arg.length)  \/\/ Property 'length' does not exist on type 'Type'.  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>length<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>length<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>extends<\/code> \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">interface Lengthwise {  length: number }  function loggingIdentity&lt;Type extends Lengthwise&gt;(arg: Type): Type {  console.log(arg.length)  \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b\u043c\u0438 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 `length`  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0431\u044b\u043b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d, \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">loggingIdentity(3) \/\/ Argument of type 'number' is not assignable to parameter of type 'Lengthwise'. \/\/ \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 'number' \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u0442\u0438\u043f\u0430 'Lengthwise'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0432\u0441\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">loggingIdentity({ length: 10, value: 3 })<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ispolzovanie-tipov-parametrov-v-ogranicheniyah-dzhenerikov\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u0438\u043f\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function getProperty&lt;Type, Key extends keyof Type&gt;(obj: Type, key: Key) {  return obj[key] }  const x = { a: 1, b: 2, c: 3, d: 4 }  getProperty(x, 'a') getProperty(x, 'm') \/\/ Argument of type '&quot;m&quot;' is not assignable to parameter of type '&quot;a&quot; | &quot;b&quot; | &quot;c&quot; | &quot;d&quot;'.<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ispolzovanie-tipov-klassa-v-dzhenerikah\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u0445<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0438\u043f\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function create&lt;Type&gt;(c: { new (): Type }): Type {  return new c() }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>prototype<\/code> \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043b\u044f\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class BeeKeeper {  hasMask: boolean }  class ZooKeeper {  nametag: string }  class Animal {  numLegs: number }  class Bee extends Animal {  keeper: BeeKeeper }  class Lion extends Animal {  keeper: ZooKeeper }  function createInstance&lt;A extends Animal&gt;(c: new () =&gt; A): A {  return new c() }  createInstance(Lion).keeper.nametag createInstance(Bee).keeper.hasMask<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u0438\u043a\u0441\u0438\u043d\u0430\u0445 \u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0441\u044f\u0445.<\/p>\n<p>  <\/p>\n<h1 id=\"operator-tipa-keyof\">\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 <code>keyof<\/code><\/h1>\n<p>  <\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>keyof<\/code> &quot;\u0431\u0435\u0440\u0435\u0442&quot; \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Point = { x: number, y: number } type P = keyof Point  \/\/ type P = keyof Point<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0438\u043f\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (index signature) \u0442\u0438\u043f\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>string<\/code> \u0438\u043b\u0438 <code>number<\/code>, <code>keyof<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u0442\u0438 \u0442\u0438\u043f\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Arrayish = { [n: number]: unknown } type A = keyof Arrayish  \/\/ type A = number  type Mapish = { [k: string]: boolean } type M = keyof Mapish  \/\/ type M = string | number<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>, \u0447\u0442\u043e \u0442\u0438\u043f\u043e\u043c <code>M<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>string | number<\/code>. \u042d\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043a\u043b\u044e\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 <code>JS<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>obj[0]<\/code> \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e <code>obj['0']<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f\u044b <code>keyof<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 (mapped types), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"operator-tipa-typeof\">\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 <code>typeof<\/code><\/h1>\n<p>  <\/p>\n<p><code>JS<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>typeof<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">console.log(typeof '\u041f\u0440\u0438\u0432\u0435\u0442, \u043d\u0430\u0440\u043e\u0434!') \/\/ string<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>TS<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>typeof<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const s = '\u043f\u0440\u0438\u0432\u0435\u0442' const n: typeof s  \/\/ const n: string<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>typeof<\/code> \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 <code>ReturnType&lt;T&gt;<\/code>. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Predicate = (x: unknown) =&gt; boolean type K = ReturnType&lt;Predicate&gt;  \/\/ type K = boolean<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>ReturnType<\/code>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function f() {  return { x: 10, y: 3 } } type P = ReturnType&lt;f&gt; \/\/ 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? \/\/ 'f' \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0438\u043f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0438\u043c\u0435\u043b\u0438 \u0432\u0432\u0438\u0434\u0443 'typeof f'<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0417\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435<\/em>: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b \u2014 \u044d\u0442\u043e \u043d\u0435 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435. \u0414\u043b\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>f<\/code> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>typeof<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function f() {  return { x: 10, y: 3 } } type P = ReturnType&lt;typeof f&gt;  \/\/ type P = { x: number, y: number }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ogranicheniya\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p><code>TS<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u044b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>typeof<\/code>.<\/p>\n<p>  <\/p>\n<p><code>typeof<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445) \u0438\u043b\u0438 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ \u0414\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ReturnType&lt;typeof msgbox&gt;, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 const shouldContinue: typeof msgbox('\u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c?') \/\/ ',' expected<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"tipy-dostupa-po-indeksu-indexed-access-types\">\u0422\u0438\u043f\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 (indexed access types)<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Person = { age: number, name: string, alive: boolean } type Age = Person['age']  \/\/ type Age = number<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0438\u043f, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, <code>keyof<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type I1 = Person['age' | 'name']  \/\/ type I1 = string | number  type I2 = Person[keyof Person]  \/\/ type I2 = string | number | boolean  type AliveOrName = 'alive' | 'name' type I3 = Person[AliveOrName]  \/\/ type I3 = string | boolean<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type I1 = Person['alve'] \/\/ Property 'alve' does not exist on type 'Person'.<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>number<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>typeof<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const MyArray = [  { name: 'Alice', age: 15 },  { name: 'Bob', age: 23 },  { name: 'John', age: 38 }, ]  type Person = typeof MyArray[number]  type Person = {    name: string    age: number } type Age = typeof MyArray[number]['age']  type Age = number \/\/ \u0438\u043b\u0438 type Age2 = Person['age']  type Age2 = number<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>const<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const key = 'age' type Age = Person[key] \/*  Type 'any' cannot be used as an index type.  'key' refers to a value, but is being used as a type here. Did you mean 'typeof key'? *\/ \/*  \u0422\u0438\u043f 'any' \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430.  'key' \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0438\u043f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0438\u043c\u0435\u043b\u0438 \u0432\u0432\u0438\u0434\u0443 'typeof key' *\/<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u043e\u043d\u0438\u043c \u0442\u0438\u043f\u0430 (type alias):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type key = 'age' type Age = Person[key]<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"uslovnye-tipy-conditional-types\">\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (conditional types)<\/h1>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e, \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 <code>TS<\/code> \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">interface Animal {  live(): void } interface Dog extends Animal {  woof(): void }  type Example1 = Dog extends Animal ? number : string  \/\/ type Example1 = number  type Example2 = RegExp extends Animal ? number : string  \/\/ type Example2 = string<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438\u043c\u0435\u044e\u0442 \u0444\u043e\u0440\u043c\u0443, \u0441\u0445\u043e\u0436\u0443\u044e \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 <code>JS<\/code> (<code>\u0443\u0441\u043b\u043e\u0432\u0438\u0435 ? \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0435\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 : \u043b\u043e\u0436\u043d\u043e\u0435\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/code>).<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">SomeType extends OtherType ? TrueType : FalseType<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0438\u043f \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 <code>extends<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u0442\u0438\u043f\u0443 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 <code>extends<\/code>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 (\u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439), \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 (\u043b\u043e\u0436\u043d\u043e\u0439).<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u044c\u0437\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430. \u041e\u043d\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u044f\u0432\u043d\u043e\u0439 \u043f\u0440\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 (\u043e\u0431\u0449\u0438\u0445 \u0442\u0438\u043f\u043e\u0432).<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">interface IdLabel {  id: number \/* \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f *\/ } interface NameLabel {  name: string \/* \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f *\/ }  function createLabel(id: number): IdLabel function createLabel(name: string): NameLabel function createLabel(nameOrId: string | number): IdLabel | NameLabel function createLabel(nameOrId: string | number): IdLabel | NameLabel {  throw '\u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e' }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 <code>createLabel<\/code> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0438\u043f\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em> \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0415\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c.<\/li>\n<li>\u041d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c 3 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438: \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u0442\u0438\u043f\u0435 (\u043e\u0434\u043d\u0443 \u0434\u043b\u044f <code>string<\/code> \u0438 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f <code>number<\/code>), \u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f (<code>string<\/code> \u0438\u043b\u0438 <code>number<\/code>). \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type NameOrId&lt;T extends number | string&gt; = T extends number  ? IdLabel  : NameLabel<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0438\u0437\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function createLabel&lt;T extends number | string&gt;(idOrName: T): NameOrId&lt;T&gt; {  throw '\u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e' }  let a = createLabel('typescript')  \/\/ let a: NameLabel  let b = createLabel(2.8)  \/\/ let b: IdLabel  let c = createLabel(Math.random() ? 'hello' : 42)  \/\/ let c: NameLabel | IdLabel<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ogranicheniya-uslovnyh-tipov\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u043c \u0442\u0438\u043f\u0435 \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0441\u0443\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0449\u0438\u0442\u043d\u0438\u043a\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u0435\u0439 \u0442\u0438\u043f\u0430 (type guards) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f, \u0438\u043d\u0441\u0442\u0438\u043d\u043d\u0430\u044f \u0432\u0435\u0442\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043f\u043e \u0442\u0438\u043f\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type MessageOf&lt;T&gt; = T['message'] \/\/ Type '&quot;message&quot;' cannot be used to index type 'T'. \/\/ \u0422\u0438\u043f '&quot;message&quot;' \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 'T'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>TS<\/code> \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0443 <code>T<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>message<\/code>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c <code>T<\/code>, \u0438 \u0442\u043e\u0433\u0434\u0430 <code>TS<\/code> \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 &quot;\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c\u0441\u044f&quot;:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type MessageOf&lt;T extends { message: unknown }&gt; = T['message']  interface Email {  message: string }  interface Dog {  bark(): void }  type EmailMessageContents = MessageOf&lt;Email&gt;  \/\/ type EmailMessageContents = string<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b <code>MessageOf<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f, \u0430 \u0435\u0433\u043e &quot;\u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c&quot; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b \u0442\u0438\u043f <code>never<\/code>? \u041c\u044b \u043c\u043e\u0436\u0435\u043c &quot;\u0432\u044b\u043d\u0435\u0441\u0442\u0438&quot; \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0442\u0438\u043f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type MessageOf&lt;T&gt; = T extends { message: unknown } ? T['message'] : never  interface Email {  message: string }  interface Dog {  bark(): void }  type EmailMessageContents = MessageOf&lt;Email&gt;  \/\/ type EmailMessageContents = string  type DogMessageContents = MessageOf&lt;Dog&gt;  \/\/ type DogMessageContents = never<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0438, <code>TS<\/code> \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e <code>T<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>message<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0438\u043f <code>Flatten<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0438\u043f\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0430 \u0442\u0438\u043f\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Flatten&lt;T&gt; = T extends any[] ? T[number] : T  \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 type Str = Flatten&lt;string[]&gt;  \/\/ type Str = string  \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0438\u043f type Num = Flatten&lt;number&gt;  \/\/ type Num = number<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 <code>Flatten<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0438\u043f \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>number<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>string[]<\/code>. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0435\u043c\u0443 \u0442\u0438\u043f.<\/p>\n<p>  <\/p>\n<h2 id=\"predpolozheniya-v-uslovnyh-tipah\">\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0441\u043e\u0431\u0430\u044f \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0435 \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>infer<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u043e <code>Flatten<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Flatten&lt;Type&gt; = Type extends Array&lt;infer Item&gt; ? Item : Type<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>infer<\/code> \u0434\u043b\u044f \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 <code>Item<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>T<\/code> \u0432 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0435. \u042d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 &quot;\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f&quot; \u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u0432 \u0442\u0438\u043f\u0430 (type aliases) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>infer<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type GetReturnType&lt;Type&gt; = Type extends (...args: never[]) =&gt; infer Return  ? Return  : never  type Num = GetReturnType&lt;() =&gt; number&gt;  \/\/ type Num = number  type Str = GetReturnType&lt;(x: string) =&gt; string&gt;  \/\/ type Str = string  type Bools = GetReturnType&lt;(a: boolean, b: boolean) =&gt; boolean[]&gt;  \/\/ type Bools = boolean[]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0438\u043f\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 (\u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u043a \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438), \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b. \u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">declare function stringOrNum(x: string): number declare function stringOrNum(x: number): string declare function stringOrNum(x: string | number): string | number  type T1 = ReturnType&lt;typeof stringOrNum&gt;  \/\/ type T1 = string | number<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"raspredelennye-uslovnye-tipy-distributive-conditional-types\">\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (distributive conditional types)<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c, \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (union). \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type ToArray&lt;Type&gt; = Type extends any ? Type[] : never<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 <code>ToArray<\/code>, \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0442\u0438\u043f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u043b\u0435\u043d\u0443 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type ToArray&lt;Type&gt; = Type extends any ? Type[] : never  type StrArrOrNumArr = ToArray&lt;string | number&gt;  \/\/ type StrArrOrNumArr = string[] | number[]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c <code>StrOrNumArray<\/code> \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">string | number<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u043b\u0435\u043d\u0443 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">ToArray&lt;string&gt; | ToArray&lt;number&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">string[] | number[]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e, \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c. \u0414\u043b\u044f \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 <code>extends<\/code> \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type ToArrayNonDist&lt;Type&gt; = [Type] extends [any] ? Type[] : never  \/\/ 'StrOrNumArr' \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c type StrOrNumArr = ToArrayNonDist&lt;string | number&gt;  \/\/ type StrOrNumArr = (string | number)[]<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"svyazannye-tipy-mapped-types\">\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (mapped types)<\/h1>\n<p>  <\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type OnlyBoolsAndHorses = {  [key: string]: boolean | Horse }  const conforms: OnlyBoolsAndHorses = {  del: true,  rodney: false, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u2014 \u044d\u0442\u043e \u043e\u0431\u0449\u0438\u0439 \u0442\u0438\u043f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>keyof<\/code>, \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043a\u043b\u044e\u0447\u0435\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0446\u0435\u043b\u044f\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type OptionsFlags&lt;Type&gt; = {  [Property in keyof Type]: boolean }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>OptionsFlag<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u0430 <code>Type<\/code> \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 <code>boolean<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type FeatureFlags = {  darkMode: () =&gt; void  newUserProfile: () =&gt; void }  type FeatureOptions = OptionsFlags&lt;FeatureFlags&gt;  \/\/ type FeatureOptions = { darkMode: boolean, newUserProfile: boolean }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"modifikatory-svyazyvaniya-mapping-modifiers\">\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f (mapping modifiers)<\/h2>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432: <code>readonly<\/code> \u0438 <code>?<\/code>, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c (\u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c) \u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432 <code>-<\/code> \u0438\u043b\u0438 <code>+<\/code>. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f <code>+<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b `readonly` \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 type CreateMutable&lt;Type&gt; = {  -readonly [Property in keyof Type]: Type[Property] }  type LockedAccount = {  readonly id: string  readonly name: string }  type UnlockedAccount = CreateMutable&lt;LockedAccount&gt;  \/\/ type UnlockedAccount = { id: string, name: string }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b `optional` \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 type Concrete&lt;Type&gt; = {  [Property in keyof Type]-?: Type[Property] }  type MaybeUser = {  id: string  name?: string  age?: number }  type User = Concrete&lt;MaybeUser&gt;  \/\/ type User = { id: string, name: string, age: number }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"povtornoe-svyazyvanie-klyuchey-s-pomoschyu-as\">\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as<\/code><\/h2>\n<p>  <\/p>\n<p>\u0412 <code>TS<\/code> 4.1 \u0438 \u0432\u044b\u0448\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0443 <code>as<\/code> \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c \u0442\u0438\u043f\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type MappedTypeWithNewProperties&lt;Type&gt; = {  [Properties in keyof Type as NewKeyType]: Type[Properties] }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0442\u0438\u043f\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 (\u0441\u043c. \u043d\u0438\u0436\u0435):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Getters&lt;Type&gt; = {  [Property in keyof Type as `get${Capitalize&lt;string &amp; Property&gt;}`]: () =&gt; Type[Property] }  interface Person {  name: string  age: number  location: string }  type LazyPerson = Getters&lt;Person&gt;  \/\/ type LazyPerson = { getName: () =&gt; string, getAge: () =&gt; number, getLocation: () =&gt; string }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>never<\/code> \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u043c \u0442\u0438\u043f\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e `kind` type RemoveKindField&lt;Type&gt; = {    [Property in keyof Type as Exclude&lt;Property, 'kind'&gt;]: Type[Property] }  interface Circle {  kind: 'circle'  radius: number }  type KindlessCircle = RemoveKindField&lt;Circle&gt;  \/\/ type KindlessCircle = { radius: number }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>true<\/code> \u0438\u043b\u0438 <code>false<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>pii<\/code> \u0441 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c <code>true<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type ExtractPII&lt;Type&gt; = {  [Property in keyof Type]: Type[Property] extends { pii: true } ? true : false }  type DBFields = {  id: { format: 'incrementing' }  name: { type: string, pii: true } }  type ObjectsNeedingGDPRDeletion = ExtractPII&lt;DBFields&gt;  \/\/ type ObjectsNeedingGDPRDeletion = { id: false, name: true }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"tipy-shablonnyh-literalov-template-literal-types\">\u0422\u0438\u043f\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 (template literal types)<\/h1>\n<p>  <\/p>\n<p>\u0422\u0438\u043f\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0442\u0438\u043f\u0430\u0445 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u0438 \u0438\u043c\u0435\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0447\u0442\u043e \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u0432 <code>JS<\/code>, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445 \u0442\u0438\u043f\u0430. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type World = 'world'  type Greeting = `hello ${World}`  \/\/ type Greeting = 'hello world'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0438\u043f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u0436\u0434\u044b\u043c \u0447\u043b\u0435\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type EmailLocaleIDs = 'welcome_email' | 'email_heading' type FooterLocaleIDs = 'footer_title' | 'footer_sendoff'  type AllLocaleIDs = `${EmailLocaleIDs | FooterLocaleIDs}_id` \/*  type AllLocaleIDs = 'welcome_email_id' | 'email_heading_id' | 'footer_title_id' | 'footer_sendoff_id' *\/<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type AllLocaleIDs = `${EmailLocaleIDs | FooterLocaleIDs}_id` type Lang = 'en' | 'ja' | 'pt'  type LocaleMessageIDs = `${Lang}_${AllLocaleIDs}` \/*  type LocaleMessageIDs = 'en_welcome_email_id' | 'en_email_heading_id' | 'en_footer_title_id' | 'en_footer_sendoff_id' | 'ja_welcome_email_id' | 'ja_email_heading_id' | 'ja_footer_title_id' | 'ja_footer_sendoff_id' | 'pt_welcome_email_id' | 'pt_email_heading_id' | 'pt_footer_title_id' | 'pt_footer_sendoff_id' *\/<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0432 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445.<\/p>\n<p>  <\/p>\n<h2 id=\"strokovye-obedineniya-v-tipah\">\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0438\u043f\u0430\u0445<\/h2>\n<p>  <\/p>\n<p>\u041c\u043e\u0449\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0432 \u043f\u043e\u043b\u043d\u043e\u0439 \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0438\u043f\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0432 <code>JS<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>on<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const person = makeWatchedObject({  firstName: 'John',  lastName: 'Smith',  age: 30, })  person.on('firstNameChanged', (newValue) =&gt; {  console.log(`\u0418\u043c\u044f \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 ${newValue}!`) })<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>, \u0447\u0442\u043e <code>on<\/code> \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>firstNameChanged<\/code>, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e <code>firstName<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type PropEventSource&lt;Type&gt; = {    on(eventName: `${string &amp; keyof Type}Changed`, callback: (newValue: any) =&gt; void): void }  \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c &quot;\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442&quot; \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c `on`, \/\/ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 declare function makeWatchedObject&lt;Type&gt;(obj: Type): Type &amp; PropEventSource&lt;Type&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">const person = makeWatchedObject({  firstName: 'John',  lastName: 'Smith',  age: 26 })  person.on('firstNameChanged', () =&gt; {})  person.on('firstName', () =&gt; {}) \/\/ Argument of type '&quot;firstName&quot;' is not assignable to parameter of type '&quot;firstNameChanged&quot; | &quot;lastNameChanged&quot; | &quot;ageChanged&quot;'. \/\/ \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 '&quot;firstName&quot;' \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u0442\u0438\u043f\u0443...  person.on('frstNameChanged', () =&gt; {}) \/\/ Argument of type '&quot;firstNameChanged&quot;' is not assignable to parameter of type '&quot;firstNameChanged&quot; | &quot;lastNameChanged&quot; | &quot;ageChanged&quot;'.<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"predpolozheniya-tipov-s-pomoschyu-shablonnyh-literalov\">\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0442\u0438\u043f\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u0438\u043f <code>any<\/code>. \u0422\u0438\u043f\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 <code>eventName<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type PropEventSource&lt;Type&gt; = {  on&lt;Key extends string &amp; keyof Type&gt;    \/\/ (eventName: `${Key}Changed`, callback: (newValue: Type[Key]) =&gt; void ): void }  declare function makeWatchedObject&lt;Type&gt;(obj: Type): Type &amp; PropEventSource&lt;Type&gt;  const person = makeWatchedObject({  firstName: 'Jane',  lastName: 'Air',  age: 26 })  person.on('firstNameChanged', newName =&gt; {                          \/\/ (parameter) newName: string    console.log(`\u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f - ${newName.toUpperCase()}`) })  person.on('ageChanged', newAge =&gt; {                    \/\/ (parameter) newAge: number    if (newAge &lt; 0) {        console.warn('\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435! \u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u0440\u0430\u0441\u0442')    } })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 <code>on<\/code> \u0432 \u043e\u0431\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439 <code>firstNameChanged<\/code>, <code>TS<\/code> \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f <code>Key<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e <code>TS<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f <code>Key<\/code> \u0441 &quot;\u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c&quot;, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 <code>Changed<\/code>, \u0438 \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u0441\u0442\u0440\u043e\u043a\u0438 <code>firstName<\/code>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>on<\/code> \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0438\u043f <code>firstName<\/code> \u0438\u0437 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0447\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>string<\/code>. \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441 <code>ageChanged<\/code>, <code>TS<\/code> \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442 \u0442\u0438\u043f \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>age<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>number<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"vnutrennie-tipy-manipulyaciy-so-strokami-intrisic-string-manipulation-types\">\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0442\u0438\u043f\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 (intrisic string manipulation types)<\/h2>\n<p>  <\/p>\n<p><code>TS<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u042d\u0442\u0438 \u0442\u0438\u043f\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <code>.d.ts<\/code>, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 <code>TS<\/code>.<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Uppercase&lt;StringType&gt;<\/code> \u2014 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Greeting = 'Hello, world' type ShoutyGreeting = Uppercase&lt;Greeting&gt;  \/\/ type ShoutyGreeting = 'HELLO, WORLD'  type ASCIICacheKey&lt;Str extends string&gt; = `ID-${Uppercase&lt;Str&gt;}` type MainID = ASCIICacheKey&lt;'my_app'&gt;  \/\/ type MainID = 'ID-MY_APP'<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>Lowercase&lt;StringType&gt;<\/code> \u2014 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type Greeting = 'Hello, world' type QuietGreeting = Lowercase&lt;Greeting&gt;  \/\/ type QuietGreeting = 'hello, world'  type ASCIICacheKey&lt;Str extends string&gt; = `id-${Lowercase&lt;Str&gt;}` type MainID = ASCIICacheKey&lt;'MY_APP'&gt;  \/\/ type MainID = 'id-my_app'<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>Capitilize&lt;StringType&gt;<\/code> \u2014 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type LowercaseGreeting = 'hello, world' type Greeting = Capitalize&lt;LowercaseGreeting&gt;  \/\/ type Greeting = 'Hello, world'<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>Uncapitilize&lt;StringType&gt;<\/code> \u2014 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">type UppercaseGreeting = 'HELLO WORLD' type UncomfortableGreeting = Uncapitalize&lt;UppercaseGreeting&gt;  \/\/ type UncomfortableGreeting = 'hELLO WORLD'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u0438 \u0442\u0438\u043f\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function applyStringMapping(symbol: Symbol, str: string) {  switch (intrinsicTypeKinds.get(symbol.escapedName as string)) {    case IntrinsicTypeKind.Uppercase: return str.toUpperCase()    case IntrinsicTypeKind.Lowercase: return str.toLowerCase()    case IntrinsicTypeKind.Capitalize: return str.charAt(0).toUpperCase() + str.slice(1)    case IntrinsicTypeKind.Uncapitalize: return str.charAt(0).toLowerCase() + str.slice(1)  }  return str }<\/code><\/pre>\n<p>  <\/p>\n<hr>\n<p>  <\/p>\n<p>\u041e\u0431\u043b\u0430\u0447\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u043e\u0442 <a href=\"https:\/\/macloud.ru\/?partner=4189mjxpzx\">\u041c\u0430\u043a\u043b\u0430\u0443\u0434<\/a> \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435 \u0438\u043b\u0438 \u043a\u043b\u0438\u043a\u043d\u0443\u0432 \u043d\u0430 \u0431\u0430\u043d\u043d\u0435\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 10% \u0441\u043a\u0438\u0434\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u0430\u0440\u0435\u043d\u0434\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438!<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/macloud.ru\/?partner=4189mjxpzx&amp;utm_source=habr&amp;utm_medium=perevod&amp;utm_campaign=igor\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/et\/1a\/yp\/et1aypandyuamqprsz3m2ntm4ky.png\"><\/a><\/p>\n<\/div>\n<p> \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\/macloud\/blog\/562786\/\"> https:\/\/habr.com\/ru\/company\/macloud\/blog\/562786\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ad\/rw\/w4\/adrww41gv8k_vuxeswr0-xkl57y.png\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/intro.html\"><code> &quot;\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e TypeScript<\/code>&quot;.<\/a>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/559902\/\">\u0427\u0430\u0441\u0442\u044c 1. \u041e\u0441\u043d\u043e\u0432\u044b<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/559976\/\">\u0427\u0430\u0441\u0442\u044c 2. \u0422\u0438\u043f\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/560594\/\">\u0427\u0430\u0441\u0442\u044c 3. \u0421\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/561470\/\">\u0427\u0430\u0441\u0442\u044c 4. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/macloud\/blog\/562054\/\">\u0427\u0430\u0441\u0442\u044c 5. \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 <code>TS<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u043e\u0439 \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0438\u043b\u0438 \u043e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b (generics). \u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0442\u0438\u043f\u0430. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0443 \u043d\u0430\u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h1 id=\"dzheneriki\">\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/h1>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>identity<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity(arg: number): number {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f <code>any<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity(arg: any): any {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u043d\u0430\u0442\u044c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0438\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">function identity&lt;Type&gt;(arg: Type): Type {  return arg }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>Type<\/code> \u043a\u0430\u043a \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\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-324945","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324945","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=324945"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324945\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}