{"id":339046,"date":"2022-09-29T15:00:54","date_gmt":"2022-09-29T15:00:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=339046"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=339046","title":{"rendered":"<span>TypeScript \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445. \u0427\u0430\u0441\u0442\u044c 3<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0438\u0437 \u0441\u0435\u0440\u0438\u0438 <a href=\"https:\/\/medium.com\/@bytefer\/list\/mastering-typescript-series-688ee7c12807\">Mastering TypeScript<\/a>, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e <a href=\"https:\/\/www.typescriptlang.org\/\">TypeScript<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/682748\/\">\u0417\u0430\u043c\u0435\u0442\u043a\u0430 \u043e Mapped Types \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e TypeScript<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/685954\/\">TypeScript \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445. \u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/687806\/\">TypeScript \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445. \u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/my-js.org\/docs\/guide\/ts\">\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430 \u043f\u043e TypeScript<\/a><\/li>\n<li><a href=\"https:\/\/my-js.org\/docs\/cheatsheet\/ts\">\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043f\u043e TypeScript<\/a><\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"15-vstroennyh-utilit-tipa\">15 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0442\u0438\u043f\u0430<\/h2>\n<p>  <\/p>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u044b \u0442\u0438\u043f\u0430 (utility types) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043b\u0435\u0433\u043a\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0442\u0438\u043f\u044b, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0438\u043f\u043e\u0432 \u0438 \u0442\u0438\u043f\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<h3 id=\"1-partialtype\">1. <code>Partial&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>Type<\/code> \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/on\/uj\/vi\/onujvikybbefyno8n8y6eolvcce.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/on\/uj\/vi\/onujvikybbefyno8n8y6eolvcce.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Make all properties in T optional.  * typescript\/lib\/lib.es5.d.ts  *\/ type Partial&lt;T> = {     [P in keyof T]?: T[P]; };<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1x\/2g\/mi\/1x2gmisencmrmup8w_uwgwqvaui.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/1x\/2g\/mi\/1x2gmisencmrmup8w_uwgwqvaui.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"2-requiredtype\">2. <code>Required&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>Type<\/code> \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 (\u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <code>Partial<\/code>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/nl\/w5\/xm\/nlw5xmusrdzm-bf01b9vb6w1_n4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/nl\/w5\/xm\/nlw5xmusrdzm-bf01b9vb6w1_n4.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Make all properties in T required.  * typescript\/lib\/lib.es5.d.ts  *\/ type Required&lt;T> = {     [P in keyof T]-?: T[P]; };<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sx\/q1\/gp\/sxq1gprrrckhlu9navjtfvcvwqs.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/sx\/q1\/gp\/sxq1gprrrckhlu9navjtfvcvwqs.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"3-readonlytype\">3. <code>Readonly&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>Type<\/code> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f (<code>readonly<\/code>). \u0422\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c\u0438 (\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/al\/dh\/15\/aldh15kb78l_ye0xry0wyjfrz0o.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/al\/dh\/15\/aldh15kb78l_ye0xry0wyjfrz0o.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Make all properties in T readonly.  * typescript\/lib\/lib.es5.d.ts  *\/ type Readonly&lt;T> = {     readonly [P in keyof T]: T[P]; };<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kr\/vv\/li\/krvvlitbpq8vtopzkclsw4lbn-o.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/kr\/vv\/li\/krvvlitbpq8vtopzkclsw4lbn-o.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"4-recordkeys-type\">4. <code>Record&lt;Keys, Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0439 \u0442\u0438\u043f (object type), \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>Keys<\/code>, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u2014 <code>Type<\/code>. \u042d\u0442\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0442\u0438\u043f\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/lu\/kv\/_k\/lukv_kmpparbjcks9fb1k0a8dvs.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/lu\/kv\/_k\/lukv_kmpparbjcks9fb1k0a8dvs.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Construct a type with a set of properties K of type T.  * typescript\/lib\/lib.es5.d.ts  *\/ type Record&lt;K extends keyof any, T> = {     [P in K]: T; };<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"5-excludeuniontype-excludedmembers\">5. <code>Exclude&lt;UnionType, ExcludedMembers><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>UnionType<\/code> \u0432\u0441\u0435\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b (assignable) <code>ExcludedMembers<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/_q\/dd\/vz\/_qddvzasm3zp1xsdg79wkch9bdu.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/_q\/dd\/vz\/_qddvzasm3zp1xsdg79wkch9bdu.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Exclude from T those types that are assignable to U.  * typescript\/lib\/lib.es5.d.ts  *\/ type Exclude&lt;T, U> = T extends U ? never : T;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xd\/vd\/ee\/xdvdeemn3fxa7o4mcyg3rvf9txk.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/xd\/vd\/ee\/xdvdeemn3fxa7o4mcyg3rvf9txk.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"6-extracttype-union\">6. <code>Extract&lt;Type, Union><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>Type<\/code> \u0432\u0441\u0435\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b <code>Union<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ok\/bg\/xm\/okbgxmw06mtj5k1wkr6sd6ho_yw.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ok\/bg\/xm\/okbgxmw06mtj5k1wkr6sd6ho_yw.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Extract from T those types that are assignable to U.  * typescript\/lib\/lib.es5.d.ts  *\/ type Extract&lt;T, U> = T extends U ? T : never;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mc\/0z\/ir\/mc0zirbn6cvtg0xnwz0er4eal-y.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/mc\/0z\/ir\/mc0zirbn6cvtg0xnwz0er4eal-y.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"7-picktype-keys\">7. <code>Pick&lt;Type, Keys><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>Type<\/code> \u043d\u0430\u0431\u043e\u0440\u0430 (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430) \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>Keys<\/code> (<code>Keys<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u0438\u043b\u0438 \u0438\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/jz\/8m\/gp\/jz8mgpka8bqelm7zeszphd3j_cs.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/jz\/8m\/gp\/jz8mgpka8bqelm7zeszphd3j_cs.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * From T, pick a set of properties whose keys are in the union K.  * typescript\/lib\/lib.es5.d.ts  *\/ type Pick&lt;T, K extends keyof T> = {     [P in K]: T[P]; };<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/e6\/ln\/dp\/e6lndp5avgdwkt1_zx9135x7k8y.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/e6\/ln\/dp\/e6lndp5avgdwkt1_zx9135x7k8y.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"8-omittype-keys\">8. <code>Omit&lt;Type, Keys><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>Type<\/code> \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>Keys<\/code> (<code>Keys<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b \u0438\u043b\u0438 \u0438\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435) (\u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <code>Pick<\/code>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/om\/ui\/yi\/omuiyiw23w4aiaejqoz3hgp4azs.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/om\/ui\/yi\/omuiyiw23w4aiaejqoz3hgp4azs.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Construct a type with the properties of T except for those  * in type K.  * typescript\/lib\/lib.es5.d.ts  *\/ type Omit&lt;T, K extends keyof any> = Pick&lt;T, Exclude&lt;keyof T, K>>;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dx\/bt\/hu\/dxbthuhtllxklqnzorjsm3zghnm.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/dx\/bt\/hu\/dxbthuhtllxklqnzorjsm3zghnm.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"9-nonnullabletype\">9. <code>NonNullable&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>Type<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>null<\/code> \u0438 <code>undefined<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ru\/fi\/fo\/rufifo7dqykz0y4-faoo3jkhvau.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ru\/fi\/fo\/rufifo7dqykz0y4-faoo3jkhvau.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Exclude null and undefined from T.  * typescript\/lib\/lib.es5.d.ts  *\/ type NonNullable&lt;T> = T extends null | undefined ? never : T;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"10-parameterstype\">10. <code>Parameters&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 (tuple) \u0438\u0437 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Type<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/rz\/xl\/mg\/rzxlmg4ffkpmtkjsmjz-rsmstjq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/rz\/xl\/mg\/rzxlmg4ffkpmtkjsmjz-rsmstjq.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Obtain the parameters of a function type in a tuple.  * typescript\/lib\/lib.es5.d.ts  *\/ type Parameters&lt;T extends (...args: any) => any> = T extends   (...args: infer P) => any ? P : never;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"11-returntypetype\">11. <code>ReturnType&lt;Type><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>Type<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/mi\/6p\/zw\/mi6pzwjrdqa9c26swdademx-tc8.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/mi\/6p\/zw\/mi6pzwjrdqa9c26swdademx-tc8.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Obtain the return type of a function type.  * typescript\/lib\/lib.es5.d.ts  *\/ type ReturnType&lt;T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"12-uppercasestringtype\">12. <code>Uppercase&lt;StringType><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/qg\/wk\/kr\/qgwkkrhxduaefxpkgqxq9wyyl3o.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/qg\/wk\/kr\/qgwkkrhxduaefxpkgqxq9wyyl3o.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"13-lowercasestringtype\">13. <code>Lowercase&lt;StringType><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/8o\/4m\/xj\/8o4mxj7_cltqrytu8lburbuwoso.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/8o\/4m\/xj\/8o4mxj7_cltqrytu8lburbuwoso.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"14-capitilizestringtype\">14. <code>Capitilize&lt;StringType><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/dh\/ev\/k6\/dhevk6kwgahwtpcplhjju5zglae.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/dh\/ev\/k6\/dhevk6kwgahwtpcplhjju5zglae.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"15-uncapitilizestringtype\">15. <code>Uncapitilize&lt;StringType><\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pq\/d_\/au\/pqd_aurljkpe3oocrxwrd6gdxmm.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pq\/d_\/au\/pqd_aurljkpe3oocrxwrd6gdxmm.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>ConstructorParameters&lt;Type><\/code>: \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0440\u0435\u0447\u044c \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0434\u0435\u0442 \u043e \u0442\u0438\u043f\u0430\u0445). \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0442\u0435\u0436 \u0432\u0441\u0435\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 (\u0438\u043b\u0438 \u0442\u0438\u043f <code>never<\/code>, \u0435\u0441\u043b\u0438 <code>Type<\/code> \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439);<\/li>\n<li><code>InstanceType&lt;Type><\/code>: \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0438\u043f, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0438\u043f\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 <code>Type<\/code>:<\/li>\n<li><code>ThisParameterType&lt;Type><\/code>: \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u0438\u043f \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>this<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>unknown<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"10-osobennostey-klassov\">10 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d (blueprint \u2014 \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u0445\u0435\u043c\u0430), \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"1-svoystva-i-metody\">1. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<h4 id=\"11-svoystva-ekzemplyarov-i-staticheskie-svoystva\">1.1. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/h4>\n<p>  <\/p>\n<p>\u0412 <code>TS<\/code>, \u043a\u0430\u043a \u0438 \u0432 <code>JS<\/code>, \u043a\u043b\u0430\u0441\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>class<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {     name: string;      constructor(name: string) {         this.name = name;     } }<\/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 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>User<\/code> \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 <code>name<\/code>. \u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 <code>ES5<\/code>, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\"use strict\"; var User = \/** @class *\/ (function () {     function User(name) {         this.name = name;     }     return User; }());<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432, \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0422\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>static<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {     static cid: string = \"eft\";     name: string;      constructor(name: string) {         this.name = name;     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\"use strict\"; var User = \/** @class *\/ (function () {     function User(name) {         this.name = name;     }      User.cid = \"eft\";      return User; }());<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435.<\/p>\n<p>  <\/p>\n<h4 id=\"12-metody-ekzemplyarov-i-staticheskie-metody\">1.2. \u041c\u0435\u0442\u043e\u0434\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h4>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {   static cid: string = \"eft\";   name: string;    constructor(name: string) {     this.name = name;   }    static printCid() {     console.log(User.cid);   }    send(msg: string) {     console.log(`${this.name} send a message: ${msg}`);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\"use strict\"; var User = \/** @class *\/ (function () {     function User(name) {         this.name = name;     }      User.printCid = function () {         console.log(User.cid);     };      User.prototype.send = function (msg) {         console.log(\"\".concat(this.name, \" send a message: \").concat(msg));     };      User.cid = \"eft\";      return User; }());<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0441\u0430\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<\/p>\n<p>  <\/p>\n<h3 id=\"2-aksessory\">2. \u0410\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u044b<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u044b (accessors). \u0410\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0433\u0435\u0442\u0442\u0435\u0440\u044b (getters) \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b (setters) \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u0445 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User {   private _age: number = 0;    get age(): number {     return this._age;   }    set age(value: number) {     if (value > 0 &amp;&amp; value &lt;= 120) {       this._age = value;     } else {       throw new Error(\"The set age value is invalid!\");     }   } }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"3-nasledovanie\">3. \u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 (inheritance) \u2014 \u044d\u0442\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u043e\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c. \u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0436\u0434\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438. \u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \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>. \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c (base), \u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c (derived). \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b.<\/p>\n<p>  <\/p>\n<h4 id=\"31-bazovyy-klass\">3.1. \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Person {   constructor(public name: string) {}    public say(words: string) :void {     console.log(`${this.name} says\uff1a${words}`);   } }<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"32-proizvodnyy-klass\">3.2. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Developer extends Person {   constructor(name: string) {     super(name);     this.say(\"Learn TypeScript\")   } }  const bytefer = new Developer(\"Bytefer\"); \/\/ \"Bytefer says\uff1aLearn TypeScript\"<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>Developer<\/code> \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 (extends) \u043a\u043b\u0430\u0441\u0441 <code>Person<\/code>. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 <code>TS<\/code>, \u043a\u0430\u043a \u0438 \u0432 <code>JS<\/code>, \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/gc\/wm\/7d\/gcwm7dx6oqkqwczymh-j_gz74hg.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/gc\/wm\/7d\/gcwm7dx6oqkqwczymh-j_gz74hg.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c (implements) \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface CanSay {   say(words: string) :void }  interface CanWalk {   walk(): void; }  class Person implements CanSay, CanWalk {   constructor(public name: string) {}    public say(words: string) :void {     console.log(`${this.name} says\uff1a${words}`);   }    public walk(): void {     console.log(`${this.name} walk with feet`);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 (concrete). \u0412 <code>TS<\/code> \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 (abstract) \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  <\/p>\n<h3 id=\"4-abstraktnye-klassy\">4. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/h3>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b, \u043f\u043e\u043b\u044f \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c\u0438. \u041a\u043b\u0430\u0441\u0441, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>abstract<\/code>, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f (instantiate) \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tw\/tu\/ms\/twtumsoeqs2dpjsv61zkuuxf69y.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tw\/tu\/ms\/twtumsoeqs2dpjsv61zkuuxf69y.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b (subclasses) \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Developer extends Person {   constructor(name: string) {     super(name);   }    say(words: string): void {     console.log(`${this.name} says ${words}`);   } }  const bytefer = new Developer(\"Bytefer\");  bytefer.say(\"I love TS!\"); \/\/ Bytefer says I love TS!<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"5-vidimost-chlenov\">5. \u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u043b\u0435\u043d\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0412 <code>TS<\/code> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e (visibility) \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <code>public<\/code>, <code>protected<\/code> \u0438 <code>private<\/code>. \u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0447\u043b\u0435\u043d\u0430\u043c \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h4 id=\"51-public\">5.1. <code>public<\/code><\/h4>\n<p>  <\/p>\n<p>\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>public<\/code>. \u0422\u0430\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Person {   constructor(public name: string) {}    public say(words: string) :void {     console.log(`${this.name} says\uff1a${words}`);   } }<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"52-protected\">5.2. <code>protected<\/code><\/h4>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u043c\u0438. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u043c \u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043e\u0442 \u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430\u0445:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/0x\/ga\/iz\/0xgaizlphfh5sq85yin5atmnmnu.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/0x\/ga\/iz\/0xgaizlphfh5sq85yin5atmnmnu.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Developer extends Person {   constructor(name: string) {     super(name);      console.log(`Base Class\uff1a${this.getClassName()}`);   } } const bytefer = new Developer(\"Bytefer\"); \/\/ \"Base Class\uff1aPerson\"<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"53-private\">5.3. <code>private<\/code><\/h4>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0447\u043b\u0435\u043d\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043d\u044b\u043c\u0438 (\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c\u0438). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u043c \u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/is\/m2\/na\/ism2naudiz0kqojc_vkvozaov3k.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/is\/m2\/na\/ism2naudiz0kqojc_vkvozaov3k.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: <code>private<\/code> \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0447\u043b\u0435\u043d\u043e\u0432 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438. \u042d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 (\u043a\u0430\u043a \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>_<\/code> \u0432 <code>JS<\/code>). \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\"use strict\"; var Person = \/** @class *\/ (function () {     function Person(id, name) {         this.id = id;         this.name = name;     }      return Person; }());  var p1 = new Person(28, \"bytefer\");<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"54-chastnye-polya\">5.4. \u0427\u0430\u0441\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f<\/h4>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 <code>TS<\/code>, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 <code>3.8<\/code> (\u0430 \u0432 <code>JS<\/code> \u2014 \u0441 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pv\/ck\/0f\/pvck0fojwqvkr3xns6tk0nd-ip4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pv\/ck\/0f\/pvck0fojwqvkr3xns6tk0nd-ip4.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\"use strict\"; var __classPrivateFieldSet = \/\/ \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434; var _Person_name;  class Person {     constructor(name) {         _Person_name.set(this, void 0);         __classPrivateFieldSet(this, _Person_name, name, \"f\");     } }  _Person_name = new WeakMap();  const bytefer = new Person(\"Bytefer\");<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0447\u0430\u0441\u0442\u043d\u044b\u043c\u0438 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u0435\u0434\u0435\u043d\u044b \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 <code>#<\/code>;<\/li>\n<li>\u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441;<\/li>\n<li>\u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (<code>public<\/code> \u0438 \u0434\u0440.);<\/li>\n<li>\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<h4 id=\"6-vyrazhenie-klassa\">6. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430<\/h4>\n<p>  <\/p>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (class expression) \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u044f\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041a\u0430\u043a \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const MyClass = class [className] [extends] {   \/\/ \u0442\u0435\u043b\u043e \u043a\u043b\u0430\u0441\u0441\u0430 };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>Point<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const Point = class {   constructor(public x: number, public y: number) {}    public length() {     return Math.sqrt(this.x * this.x + this.y * this.y);   } }  const p = new Point(3, 4); console.log(p.length()); \/\/ 5<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>extends<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"7-obschiy-klass\">7. \u041e\u0431\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e (generic) \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>&lt;T, ...><\/code> (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0438\u043f\u0430) \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Person&lt;T> {   constructor(     public cid: T,     public name: string   ) {} }  const p1 = new Person&lt;number>(28, \"Lolo\"); const p2 = new Person&lt;string>(\"eft\", \"Bytefer\");<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>p1<\/code>:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Person<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f <code>number<\/code> \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430;<\/li>\n<li>\u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Person<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430 <code>T<\/code> \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c;<\/li>\n<li>\u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>cid<\/code> \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u043b\u0443\u0447\u0430\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0435 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"8-signatura-konstruktora\">8. \u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>new<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface Point {   new (x: number, y: number): Point; }<\/code><\/pre>\n<p>  <\/p>\n<p><code>new (x: number, y: number)<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 (construct signature). \u041e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">ConstructSignature: new TypeParametersopt ( ParameterListopt ) TypeAnnotationopt<\/code><\/pre>\n<p>  <\/p>\n<p><code>TypeParametersopt<\/code>, <code>ParameterListopt<\/code> \u0438 <code>TypeAnnotationopt<\/code> \u2014 \u044d\u0442\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430, \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430? \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface Point {   new (x: number, y: number): Point;   x: number;   y: number; }  class Point2D implements Point {   readonly x: number;   readonly y: number;  constructor(x: number, y: number) {     this.x = x;     this.y = y;   } }  const point: Point = new Point2D(1, 2); \/\/ Error<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">Type 'Point2D' is not assignable to type 'Point'.  Type 'Point2D' provides no match for the signature 'new (x: number, y: number): Point'.ts(2322)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>Point<\/code> \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface Point {   x: number;   y: number; }  interface PointConstructor {   new (x: number, y: number): Point; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>newPoint<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Point<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0443 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <code>PointConstructor<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Point2D implements Point {   readonly x: number;   readonly y: number;   constructor(x: number, y: number) {     this.x = x;     this.y = y;   } }  function newPoint(   pointConstructor: PointConstructor,   x: number,   y: number ): Point {   return new pointConstructor(x, y); }  const point: Point = newPoint(Point2D, 3, 4);<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"9-abstraktnaya-signatura-konstruktora\">9. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 <code>TS 4.2<\/code> \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type Constructor = new (...args: any[]) => any;  abstract class Shape {   abstract getArea(): number; }  const Ctor: Constructor = Shape; \/\/ Error \/\/ Type 'typeof Shape' is not assignable to type 'Constructor'. \/\/  Cannot assign an abstract constructor type to a non-abstract \/\/ constructor type.ts(2322)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0438\u043f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0438\u043f\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type AbstractConstructor = abstract new (...args: any[]) => any;  abstract class Shape {   abstract getArea(): number; }  const Ctor: AbstractConstructor = Shape; \/\/ Ok<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>makeSubclassWithArea<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Shape<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function makeSubclassWithArea(Ctor: AbstractConstructor) {   return class extends Ctor {     #sideLength: number;      constructor(sideLength: number) {       super();       this.#sideLength = sideLength;     }      getArea() {       return this.#sideLength ** 2;     }   }; }  const Square = makeSubclassWithArea(Shape);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0442\u0438\u043f\u0430\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">abstract class Shape {   abstract getArea(): number; }  class Square extends Shape {   #sideLength: number;    constructor(sideLength: number) {     super();     this.#sideLength = sideLength;   }    getArea() {     return this.#sideLength ** 2;   } }  const Ctor: AbstractConstructor = Shape; \/\/ Ok const Ctor1: AbstractConstructor = Square; \/\/ Ok<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u043e\u043c <code>class<\/code> \u0438 \u0442\u0438\u043f\u043e\u043c <code>typeof class<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"10-tip-class-i-tip-typeof-class\">10. \u0422\u0438\u043f <code>class<\/code> \u0438 \u0442\u0438\u043f <code>typeof class<\/code><\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/22\/if\/uu\/22ifuulix6us48yguv9hkf-y2yc.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/22\/if\/uu\/22ifuulix6us48yguv9hkf-y2yc.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Person<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430;<\/li>\n<li>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>typeof Person<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 <code>TS<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (structured type system), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (nominal type system), \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0432 <code>Java\/C++<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>TS<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Person {   constructor(public name: string) {} }  class SuperMan {   constructor(public name: string) {} }  const s1: SuperMan = new Person(\"Bytefer\"); \/\/ Ok<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"opredelenie-obekta-s-neizvestnymi-svoystvami\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043b\u0438 \u0432\u0430\u043c \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/1_\/0f\/4a\/1_0f4ailh0gbqndiyyl5edtwcjy.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/1_\/0f\/4a\/1_0f4ailh0gbqndiyyl5edtwcjy.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0438\u043f\u0430 <code>any<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">consr user: any = {}  user.id = \"TS001\"; user.name = \"Bytefer\";<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438 \u043d\u0438\u0432\u0435\u043b\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>TS<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>type<\/code> \u0438\u043b\u0438 <code>interface<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface User {   id: string;   name: string; }  const user = {} as User; user.id = \"TS001\"; user.name = \"Bytefer\";<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>age<\/code>?<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">Property 'age' does not exist on type 'User'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u041a\u043e\u0433\u0434\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0442\u0438\u043f\u044b \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 (index signatures). \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/xw\/s9\/wr\/xws9wrbv25mbblab2p38xnxvi00.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/xw\/s9\/wr\/xws9wrbv25mbblab2p38xnxvi00.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0442\u0438\u043f\u043e\u043c \u043a\u043b\u044e\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a\u0430, \u0447\u0438\u0441\u043b\u043e, \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/qp\/15\/vr\/qp15vrykj22bebwkoin7sqz3wko.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/qp\/15\/vr\/qp15vrykj22bebwkoin7sqz3wko.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f <code>User<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \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:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface User {   id: string;   name: string;   [key: string]: string; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \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 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ob\/-t\/g1\/ob-tg1l1_ovk-fk1unluoiym4m0.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ob\/-t\/g1\/ob-tg1l1_ovk-fk1unluoiym4m0.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0447\u0435\u043c\u0443 \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 <code>\"1\"<\/code>, \u0442\u0430\u043a \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0447\u0438\u0441\u043b\u0430 <code>1<\/code>?<\/li>\n<li>\u041f\u043e\u0447\u0435\u043c\u0443 <code>keyof NumbersNames<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0447\u0438\u0441\u043b\u0430?<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e <code>JS<\/code> \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0447\u0438\u0441\u043b\u043e \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <code>TS<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\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 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0442\u0438\u043f\u0430 <code>Record<\/code>. \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/lu\/kv\/_k\/lukv_kmpparbjcks9fb1k0a8dvs.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/lu\/kv\/_k\/lukv_kmpparbjcks9fb1k0a8dvs.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">type User = Record&lt;string, string>  const user = {} as User; user.id = \"TS001\"; \/\/ Ok user.name = \"Bytefer\"; \/\/ Ok<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 <code>Record<\/code>? \u041e\u043d\u0438 \u043e\u0431\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c\u0438 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438) \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const user1: Record&lt;string, string> = { name: \"Bytefer\" }; \/\/ Ok const user2: { [key: string]: string } = { name: \"Bytefer\" }; \/\/ Ok<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0442\u0438\u043f \u043a\u043b\u044e\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e <code>string<\/code>, <code>number<\/code>, <code>symbol<\/code> \u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>Record<\/code> \u043a\u043b\u044e\u0447 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u043c \u0438\u043b\u0438 \u0438\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/c3\/he\/76\/c3he76cpxzmpx7hji6nltkk0buk.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/c3\/he\/76\/c3he76cpxzmpx7hji6nltkk0buk.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>Record<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * Construct a type with a set of properties K of type T.  * typescript\/lib\/lib.es5.d.ts  *\/ type Record&lt;K extends keyof any, T> = {     [P in K]: T; };<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"peregruzki-funkcii\">\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b, \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>ref<\/code> \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/q-\/dy\/ko\/q-dykoh3l88mhiaf3thjyrw_73s.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/q-\/dy\/ko\/q-dykoh3l88mhiaf3thjyrw_73s.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>logError<\/code>, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434\u044f\u0449\u0435\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function logError(msg: string) {   console.error(`\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430: ${msg}`); }  logError('\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.');<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430?<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (union types):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function logError(msg: string | string[]) {   if (typeof msg === 'string') {     console.error(`\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430: ${msg}`);   } else if (Array.isArray(msg)) {     console.error(`\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438: ${msg.join('\\n')}`);   } }  logError('\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.') logError(['\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.', '\u041f\u0430\u0440\u043e\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u0437 6 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.'])<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (function overloading). \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 (overload signatures) \u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (implementation signature).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/od\/xs\/rx\/odxsrxaygssiqoyshhcl-2tynls.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/od\/xs\/rx\/odxsrxaygssiqoyshhcl-2tynls.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0442\u0438\u043f\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0435\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u0435\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/9w\/7j\/9v\/9w7j9vveipawkezntxbgjeyyvt4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/9w\/7j\/9v\/9w7j9vveipawkezntxbgjeyyvt4.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b. \u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/mw\/yo\/d4\/mwyod44ew2a1jw951sbp1-d4gjs.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/mw\/yo\/d4\/mwyod44ew2a1jw951sbp1-d4gjs.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/lb\/q6\/db\/lbq6dbfpnjyqvbqackl-rvn4k7i.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/lb\/q6\/db\/lbq6dbfpnjyqvbqackl-rvn4k7i.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438. \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>TS<\/code> \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/h6\/ti\/1e\/h6ti1e_ddzlh6ghyxymxrfyvoxo.gif\" data-src=\"https:\/\/habrastorage.org\/webt\/h6\/ti\/1e\/h6ti1e_ddzlh6ghyxymxrfyvoxo.gif\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0442\u0438\u043f\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/e3\/aw\/so\/e3awsoa7thonmvir6zaefnaw5py.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/e3\/aw\/so\/e3awsoa7thonmvir6zaefnaw5py.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 (\u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0442.\u0434.). \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Calculator {   add(a: number, b: number): number;   add(a: string, b: string): string;   add(a: string, b: number): string;   add(a: number, b: string): string;   add(a: string | number, b: string | number) {  if (typeof a === 'string' || typeof b === 'string') {     return a.toString() + b.toString();   }     return a + b;   } }  const calculator = new Calculator(); const result = calculator.add('Bytefer', ' likes TS');<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0432\u044b, \u043a\u0430\u043a \u0438 \u044f, \u043d\u0430\u0448\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/vds-promo-8-rub?utm_source=habr&amp;utm_medium=blog_1560_476&amp;utm_campaign=habr&amp;utm_content=1560_476\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/690726\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/690726\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/um\/fe\/t_\/umfet_kngorlggfmgokzowwtsuu.png\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0438\u0437 \u0441\u0435\u0440\u0438\u0438 <a href=\"https:\/\/medium.com\/@bytefer\/list\/mastering-typescript-series-688ee7c12807\">Mastering TypeScript<\/a>, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e <a href=\"https:\/\/www.typescriptlang.org\/\">TypeScript<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/682748\/\">\u0417\u0430\u043c\u0435\u0442\u043a\u0430 \u043e Mapped Types \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e TypeScript<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/685954\/\">TypeScript \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445. \u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/687806\/\">TypeScript \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445. \u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/my-js.org\/docs\/guide\/ts\">\u041a\u0430\u0440\u043c\u0430\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430 \u043f\u043e TypeScript<\/a><\/li>\n<li><a href=\"https:\/\/my-js.org\/docs\/cheatsheet\/ts\">\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043f\u043e TypeScript<\/a><\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-339046","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339046","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=339046"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339046\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}