{"id":351107,"date":"2023-08-01T15:04:03","date_gmt":"2023-08-01T15:04:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=351107"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=351107","title":{"rendered":"<span>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f NPM \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u0422\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u043e\u0436\u0435, \u0447\u0435\u043c \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c NPM \u043f\u0430\u043a\u0435\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0433 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430. \u0410 \u0442\u0430\u043a \u0436\u0435 \u044f \u043e\u043f\u0438\u0448\u0443, \u0437\u0430\u0447\u0435\u043c \u0438 \u043a\u043e\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f?<\/h2>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 NPM \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u043d\u043e\u0432\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Axios \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0446\u0435\u043f\u0442\u043e\u0440\u044b \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u0430\u043c\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0410 MobX, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e configure, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"typescript\">import axios from 'axios'; import { configure } from 'mobx';  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Axios axios.interceptors.response.use(   \/\/ \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 response,   \/\/  \u0430 response.data, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.    (response) => response.data,   \/\/ \u0410 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u0431\u044d\u043a\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432   \/\/  \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u0445 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.   (error) => {     if (error.response?.status === 401) {       console.error('User is not authorized');     }     if (error.response?.status === 404) {       console.error('Not found');     }     return Promise.reject(error);   } );  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 MobX configure({   \/\/ \u042d\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f   \/\/  \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439   enforceActions: 'never',   \/\/ \u0410 \u044d\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MobX \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f    \/\/  \u043e\u0431\u044a\u0435\u043a\u0442\u0430 `Proxy`   useProxies: 'never', });<\/code><\/pre>\n<p>\u041d\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u0427\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u043e\u0431\u0449\u0435?<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0441 <code>axios<\/code> \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u043e TypeScript \u043e\u0431 \u044d\u0442\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043d\u0435 \u0443\u0437\u043d\u0430\u043b. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0432\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u0443\u0434\u044c \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e.<\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b. \u0415\u0441\u043b\u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 TypeScript, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0432 \u0435\u0433\u043e \u043c\u0430\u0436\u043e\u0440\u043d\u043e\u0439 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 &#8212; <a href=\"https:\/\/github.com\/tc39\/proposal-decorators\" rel=\"noopener noreferrer nofollow\"><u>proposal<\/u><\/a>, <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-5-0\/#decorators\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0442\u0430\u0442\u044c\u044f MicroSoft<\/u><\/a>. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u044f \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432 TypeScript \u0431\u044b\u043b\u0438 \u0438 \u0440\u0430\u043d\u0435\u0435, \u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0418 , \u0447\u0442\u043e\u0431\u044b\u00a0 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c <em>tsconfig.json<\/em>.<\/p>\n<pre><code class=\"typescript\">\/\/ file.ts declare const oldExperimentalDecorator: PropertyDecorator;  export class Class {   @oldExperimentalDecorator   public property: number = 1; }  \/\/ tsconfig.json {   \"compilerOptions\": {     \/\/ ...     \"experimentalDecorators\": true,     \"emitDecoratorMetadata\": true,   },   \/\/ ... }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u201c\u0441\u0442\u0430\u0440\u044b\u0435\u201d \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u0441\u0435 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 <em>tsconfig<\/em> \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c <code>experimentalDecorators: true<\/code>, TypeScript \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043b\u0430\u0434. \u0418 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"typescript\">declare const oldExperimentalDecorator: PropertyDecorator; declare const newDecorator: &lt;This, Value>(_: unknown, context: ClassFieldDecoratorContext&lt;This, Value>) => void;  export class Class {   \/\/ If `experimentalDecorators` in tsconfig is false, or not set   \/\/ there will be a type error   @oldExperimentalDecorator   public property: number = 1;     \/\/ If `experimentalDecorators` in tsconfig is true there will   \/\/ be a type error   @newDecorator   public property1: number = 1; }<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435. \u0412\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 NPM \u043f\u0430\u043a\u0435\u0442, \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043a\u0430\u043a \u0432 \u0441\u0442\u0430\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b TypeScript \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0430\u0448 \u043a\u043e\u0434 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u043d\u0430\u0442\u044c, \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043e\u043f\u0446\u0438\u044e <code>experimentalDecorators<\/code>.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432 \u0434\u0435\u043b\u043e \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0433 \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u0430\u0441\u0438 \u0438\u043b\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u044e<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u044f \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u044b TypeScript.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 TypeScript \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/declaration-merging.html\" rel=\"noopener noreferrer nofollow\"><u>\u201c\u0441\u043b\u0438\u044f\u043d\u0438\u0435\u201d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/u><\/a>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 interface. \u0414\u043b\u044f \u044d\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c, \u0447\u0442\u043e \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c.<\/p>\n<pre><code class=\"typescript\">interface Interface {   prop1: number; }  interface Interface {   prop2: number; }  declare const value: Interface;  \/\/ \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0438 \u043a prop1, \u0438 \u043a prop2, \u0442.\u043a. \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 console.log(value.prop1, value.prop2);<\/code><\/pre>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0435 NPM \u043f\u0430\u043a\u0435\u0442, \u0435\u0433\u043e \u0438\u043c\u044f &#8212; \u0442\u043e, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 package.json &#8212; \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044f. \u0414\u0430-\u0434\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043b\u0438, \u0438\u043c\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 axios, \u043d\u043e \u043e\u0431\u043e\u0437\u0432\u0430\u0442\u044c \u0435\u0435 \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<pre><code class=\"typescript\">\/\/ package.json {   \"dependencies\": {     \"@types\/react\": \"^16.14.43\",     \"@types\/react2\": \"npm:@types\/react@18\",     \"axios\": \"^1.4.0\",     \"axixixios\": \"npm:axios@1.4.0\",     \"react\": \"^16.14.0\",     \"react2\": \"npm:react@18\"   } }  \/\/ file.ts \/\/ \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u2018react\u2019, \u2018react2\u2019, \u2018axios\u2019 \u0438 \u2018axixixios\u2019 import axios from 'axios'; import axixixios from 'axixixios'; import React from 'react'; import React2 from 'react2';<\/code><\/pre>\n<p>\u0418 \u0432-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \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>declare<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>export<\/code>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0447\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0418 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b.<\/p>\n<pre><code class=\"typescript\">import { FunctionComponent } from 'react';  declare module 'react' {   interface FunctionComponent {     newStaticProperty: number;   } }  declare const Component: FunctionComponent;  \/\/ \u041e\u0448\u0438\u0431\u043e\u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0442, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u044b\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0435\u043d\u0435\u043d\u044b console.log(Component.newStaticProperty);<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e?<\/h2>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0438\u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 NPM \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/Yoskutik\/npm-packages-types-configuration-example\" rel=\"noopener noreferrer nofollow\">\u043a\u043e \u043c\u043d\u0435 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>\u0417\u043d\u0430\u043d\u0438\u0439, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 React, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 \u0432 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  \/\/ Type must be set in the final product. | undefined is not necessary export const value: (TypesConfiguration extends {   value: unknown } ? TypesConfiguration[value] : never) | undefined = undefined;  \/\/ =====================  \/\/ file2.ts import { value } from '.\/file1'; import { expectType } from 'ts-expect';  declare module '.\/file1' {   interface TypesConfiguration {     value: string;   } } \/\/ There's no error. The type is `string | undefined` expectType&lt;string | undefined>(value); \/\/ Error. The type is `string | undefined` expectType&lt;number | undefined>(value);<\/code><\/pre>\n<p>\u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e <code>| undefined<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f \u043c\u043e\u0433 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b, \u0442\u043e \u0442\u0438\u043f \u0443 <code>value<\/code> \u0431\u044b\u043b \u0431\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a\u043e\u0439 \u0431\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 <code>TypesConfiguration<\/code>.<\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/2\/conditional-types.html#handbook-content\" rel=\"noopener noreferrer nofollow\"><u>\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/u><\/a>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0435\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043e\u043b\u0431\u044d\u043a \u043d\u0430 \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043d\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e. \u0418\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u0430\u043a \u043f\u043e \u0444\u043b\u0430\u0433\u0443 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  \/\/ Typed by flag. If flag is not used, type is string, otherwise - number. `| undefined` is not necessary export const valueTypedByFlag: (TypesConfiguration extends {   useNumber: true } ? number : string) | undefined = undefined;  \/\/ Type must be set in the final product. If the type is not set, a fallback non-strict type is used export const mapTypedWithFallback: TypesConfiguration extends { mapTypedWithFallback: unknown } ? TypesConfiguration['mapTypedWithFallback'] : Record&lt;string, number> = {};  \/\/ =====================  \/\/ file2.ts import { value, map } from '.\/file1'; import { expectType } from 'ts-expect';  declare module '.\/file1' {   interface TypesConfiguration {     \/\/ If useNumber: true is not passed, the type of `value`     \/\/  will be string     useNumber: true;      \/\/ If `map` is not passed, we can use any key in the map.     \/\/  But now only `key1` and `key2` are accessible     mapTypedWithFallback: {       key1: 1,       key2: 2,     }   } }   \/\/ No error since useNumber: true is used expectType&lt;number | undefiend>(value);  \/\/ No error console.log(map, map.key1, map.key2);  \/\/ Error if `mapTypedWithFallback` is passed console.log(map.randomKey);<\/code><\/pre>\n<h2>\u041d\u043e \u0433\u0434\u0435 \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f?<\/h2>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 \u043a \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041d\u043e \u0432\u0430\u043c \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u043d\u0430\u043a\u0438\u0434\u0430\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438<\/h3>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u041a\u0430\u043a \u0438 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>useNumber<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>TypesConfiguration<\/code> \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u0435\u043d \u0437\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  export const decorator: TypesConfiguration extends { experimentalDecorators: true }   ? PropertyDecorator   : &lt;This, Value extends number>(_: unknown, context: ClassFieldDecoratorContext&lt;This, Value>) => void;  \/\/ file2.ts import { decorator } from '.\/file1';  declare module '.\/file1' {   interface TypesConfiguration {     \/\/ Must be set to true only if it is set to true in the tsconfig file.     experimentalDecorators: true;   } }  class Class {   @decorator   property: number; }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u043b\u0435\u043d \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445. \u0415\u0441\u043b\u0438 \u0435\u043c\u0443 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 <em>tsconfig<\/em> \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u043b\u0430\u0433 <code>experimentalDecorators<\/code> \u0432 <code>true<\/code>, \u0438 \u0437\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>experimentalDecorators: true<\/code> \u0432 <code>TypesConfiguration<\/code>. \u0412 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432 tsconfig \u0438 \u0432 <code>TypesConfiguration<\/code> \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c<\/h3>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u044e \u0432 NPM \u043f\u0430\u043a\u0435\u0442\u0430\u0445 &#8212; \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043a\u043b\u044e\u0447\u0443. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 TSyringe.<\/p>\n<pre><code class=\"typescript\">import { container } from 'tsyringe';  class A { prop1: number } class B { prop2: string }  \/\/ \u0422\u0430\u043a \u043c\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c container.register('ClassA', A); container.register('ClassB', B);  \/\/ \u0410 \u0442\u0430\u043a \u0435\u0451 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c. \u0422\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0443 const a: A = container.resolve('ClassA'); const b = container.resolve&lt;B>('ClassB');<\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>register<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043b\u044e\u0447, \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0410 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>resolve<\/code> \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412 TSyringe \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>container.resolve<\/code>, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 &#8212; \u0447\u0442\u043e \u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>resolve<\/code>\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, TSyringe \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442. \u0421\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c\u044e \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0430\u0445\u043d\u0435\u0442.<\/p>\n<pre><code class=\"typescript\">const a: A = container.resolve('ClassA'); \/\/ Typed as A, although it is B const b: A = container.resolve('ClassB'); \/\/ Typed as B, although it doesn\u2019t exist const c: B = container.resolve('Unknown token');<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e. \u041c\u043e\u0436\u0435\u043c \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  type KeyToClassMap = TypesConfiguration extends { registry: unknown }   ? TypesConfiguration['registry']   : Record&lt;string, any>;  type Constructable&lt;T> = { new (...args: unknown[]): T };  const map: KeyToClassMap = {}  export type TRegister = TypesConfiguration extends { registry: unknown }   \/\/ @ts-ignore   ? &lt;Key extends keyof TypesConfiguration['registry']>(key: Key, Class: Constructable&lt;TypesConfiguration['registry'][Key]>) => void   : (key: string, Class: Constructable&lt;any>) => void;  export const register: TRegister = (key, Class) => {   map[key] = new Class(); };  export type TResolve = TypesConfiguration extends { registry: unknown }   \/\/ @ts-ignore   ? &lt;T extends keyof TypesConfiguration['registry']>(key: T) => TypesConfiguration['registry'][T]   : &lt;T>(key: string) => T;  export const resolve: TResolve = (key) => map[key];  \/\/ =====================  \/\/ file2.ts import { resolve, register } from '.\/file1';  declare module '.\/file1' {   interface TypesConfiguration {     \/\/ If we define registry here, our types become much stricter     registry: {       ClassA: A,       ClassB: B,     }   } }  class A { prop1: number } class B { prop2: string }   \/\/ Can register only `A` register('ClassA', A); \/\/ Can register only `B` register('ClassB', B);   \/\/ Can return only type A const a = resolve('ClassA'); \/\/ Can return only B. Which is why `: A` type will cause an error const b: A = resolve('ClassB'); \/\/ Unknown key will cause an error const c = resolve('Unknown token');<\/code><\/pre>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0433\u043e\u0439. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>register<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442 <code>TypesConfiguration['registry']<\/code>. \u041d\u043e \u0442\u0430\u043a \u0436\u0435 \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>resolve<\/code> \u0441 \u043a\u043b\u044e\u0447\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h2>\u041d\u0443\u0436\u043d\u043e \u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e?<\/h2>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u043d \u0440\u0435\u0448\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u043e\u043d \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0435\u043c \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432\u0430\u0448\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0438 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b &#8212; \u0434\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043d\u043e \u0432\u0430\u043c. \u041d\u043e \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u044d\u0442\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0442\u043e \u0441\u043f\u0435\u0448\u0443 \u0432\u0430\u0441 \u0437\u0430\u0432\u0435\u0440\u0438\u0442\u044c &#8212; \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0444\u043b\u0430\u0433\u0443 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0432 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430. \u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 <code>axios<\/code> &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0436\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u0442\u0435\u0445\u043d\u0438\u043a\u0438. <\/p>\n<h2>\u041a\u043e\u043d\u0435\u0446<\/h2>\n<p>\u042d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u0442\u0435\u043a\u043b\u0430 \u0438\u0437 \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u042f \u0445\u043e\u0442\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0432\u0435\u0437\u0434\u0435, \u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u0418 \u043f\u043e\u043a\u0430 \u044f \u0438\u0437\u0443\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443 TypeScript, \u0447\u0442\u043e\u0431\u044b \u0435\u0435 \u0440\u0435\u0448\u0438\u0442\u044c, \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u0440\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0442\u0435 \u0437\u043d\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0442\u044b \u0443\u0436\u0435 \u0432\u043b\u0430\u0434\u0435\u0435\u0448\u044c, \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0443\u0433\u043b\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0430\u043c\u043e\u0440\u0435\u043a\u043b\u0430\u043c\u044b \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0441 \u044f \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b <a href=\"https:\/\/habr.com\/ru\/articles\/733044\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u043b \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 EcmaScript \u0444\u0438\u0447<\/a>. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u0445, \u043c\u0438\u043b\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0438\u043c.<\/p>\n<p>\u0415\u0449\u0451 \u0440\u0430\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0443 <a href=\"https:\/\/github.com\/Yoskutik\/npm-packages-types-configuration-example\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a> \u0441 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0432 NPM \u043f\u0430\u043a\u0435\u0442\u0430\u0445 \u0441 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043d\u0430 \u0442\u0438\u043f\u044b. \u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u041f\u043e\u043a\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/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\/articles\/751318\/\"> https:\/\/habr.com\/ru\/articles\/751318\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c NPM \u043f\u0430\u043a\u0435\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0433 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430. \u0410 \u0442\u0430\u043a \u0436\u0435 \u044f \u043e\u043f\u0438\u0448\u0443, \u0437\u0430\u0447\u0435\u043c \u0438 \u043a\u043e\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f?<\/h2>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 NPM \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u043d\u043e\u0432\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Axios \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0446\u0435\u043f\u0442\u043e\u0440\u044b \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u0430\u043c\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0410 MobX, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e configure, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"typescript\">import axios from 'axios'; import { configure } from 'mobx';  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 Axios axios.interceptors.response.use(   \/\/ \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 response,   \/\/  \u0430 response.data, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.    (response) => response.data,   \/\/ \u0410 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u0431\u044d\u043a\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432   \/\/  \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u0445 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.   (error) => {     if (error.response?.status === 401) {       console.error('User is not authorized');     }     if (error.response?.status === 404) {       console.error('Not found');     }     return Promise.reject(error);   } );  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 MobX configure({   \/\/ \u042d\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f   \/\/  \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439   enforceActions: 'never',   \/\/ \u0410 \u044d\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MobX \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f    \/\/  \u043e\u0431\u044a\u0435\u043a\u0442\u0430 `Proxy`   useProxies: 'never', });<\/code><\/pre>\n<p>\u041d\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u0427\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u043e\u0431\u0449\u0435?<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0441 <code>axios<\/code> \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u043e TypeScript \u043e\u0431 \u044d\u0442\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043d\u0435 \u0443\u0437\u043d\u0430\u043b. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0432\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u0443\u0434\u044c \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e.<\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b. \u0415\u0441\u043b\u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 TypeScript, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0432 \u0435\u0433\u043e \u043c\u0430\u0436\u043e\u0440\u043d\u043e\u0439 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 &#8212; <a href=\"https:\/\/github.com\/tc39\/proposal-decorators\" rel=\"noopener noreferrer nofollow\"><u>proposal<\/u><\/a>, <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-5-0\/#decorators\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0442\u0430\u0442\u044c\u044f MicroSoft<\/u><\/a>. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u044f \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432 TypeScript \u0431\u044b\u043b\u0438 \u0438 \u0440\u0430\u043d\u0435\u0435, \u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0418 , \u0447\u0442\u043e\u0431\u044b\u00a0 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c <em>tsconfig.json<\/em>.<\/p>\n<pre><code class=\"typescript\">\/\/ file.ts declare const oldExperimentalDecorator: PropertyDecorator;  export class Class {   @oldExperimentalDecorator   public property: number = 1; }  \/\/ tsconfig.json {   \"compilerOptions\": {     \/\/ ...     \"experimentalDecorators\": true,     \"emitDecoratorMetadata\": true,   },   \/\/ ... }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u201c\u0441\u0442\u0430\u0440\u044b\u0435\u201d \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u0441\u0435 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432 \u043f\u044f\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 <em>tsconfig<\/em> \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c <code>experimentalDecorators: true<\/code>, TypeScript \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043b\u0430\u0434. \u0418 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"typescript\">declare const oldExperimentalDecorator: PropertyDecorator; declare const newDecorator: &lt;This, Value>(_: unknown, context: ClassFieldDecoratorContext&lt;This, Value>) => void;  export class Class {   \/\/ If `experimentalDecorators` in tsconfig is false, or not set   \/\/ there will be a type error   @oldExperimentalDecorator   public property: number = 1;     \/\/ If `experimentalDecorators` in tsconfig is true there will   \/\/ be a type error   @newDecorator   public property1: number = 1; }<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435. \u0412\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 NPM \u043f\u0430\u043a\u0435\u0442, \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043a\u0430\u043a \u0432 \u0441\u0442\u0430\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b TypeScript \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0430\u0448 \u043a\u043e\u0434 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u043d\u0430\u0442\u044c, \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043e\u043f\u0446\u0438\u044e <code>experimentalDecorators<\/code>.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432 \u0434\u0435\u043b\u043e \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0433 \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u0430\u0441\u0438 \u0438\u043b\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u044e<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u044f \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u044b TypeScript.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 TypeScript \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/declaration-merging.html\" rel=\"noopener noreferrer nofollow\"><u>\u201c\u0441\u043b\u0438\u044f\u043d\u0438\u0435\u201d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/u><\/a>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 interface. \u0414\u043b\u044f \u044d\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c, \u0447\u0442\u043e \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c.<\/p>\n<pre><code class=\"typescript\">interface Interface {   prop1: number; }  interface Interface {   prop2: number; }  declare const value: Interface;  \/\/ \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0438 \u043a prop1, \u0438 \u043a prop2, \u0442.\u043a. \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 console.log(value.prop1, value.prop2);<\/code><\/pre>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0435 NPM \u043f\u0430\u043a\u0435\u0442, \u0435\u0433\u043e \u0438\u043c\u044f &#8212; \u0442\u043e, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 package.json &#8212; \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044f. \u0414\u0430-\u0434\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043b\u0438, \u0438\u043c\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 axios, \u043d\u043e \u043e\u0431\u043e\u0437\u0432\u0430\u0442\u044c \u0435\u0435 \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<pre><code class=\"typescript\">\/\/ package.json {   \"dependencies\": {     \"@types\/react\": \"^16.14.43\",     \"@types\/react2\": \"npm:@types\/react@18\",     \"axios\": \"^1.4.0\",     \"axixixios\": \"npm:axios@1.4.0\",     \"react\": \"^16.14.0\",     \"react2\": \"npm:react@18\"   } }  \/\/ file.ts \/\/ \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u2018react\u2019, \u2018react2\u2019, \u2018axios\u2019 \u0438 \u2018axixixios\u2019 import axios from 'axios'; import axixixios from 'axixixios'; import React from 'react'; import React2 from 'react2';<\/code><\/pre>\n<p>\u0418 \u0432-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \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>declare<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>export<\/code>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0447\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0418 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b.<\/p>\n<pre><code class=\"typescript\">import { FunctionComponent } from 'react';  declare module 'react' {   interface FunctionComponent {     newStaticProperty: number;   } }  declare const Component: FunctionComponent;  \/\/ \u041e\u0448\u0438\u0431\u043e\u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0442, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u044b\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0435\u043d\u0435\u043d\u044b console.log(Component.newStaticProperty);<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e?<\/h2>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0438\u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 NPM \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/Yoskutik\/npm-packages-types-configuration-example\" rel=\"noopener noreferrer nofollow\">\u043a\u043e \u043c\u043d\u0435 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>\u0417\u043d\u0430\u043d\u0438\u0439, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 React, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 \u0432 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  \/\/ Type must be set in the final product. | undefined is not necessary export const value: (TypesConfiguration extends {   value: unknown } ? TypesConfiguration[value] : never) | undefined = undefined;  \/\/ =====================  \/\/ file2.ts import { value } from '.\/file1'; import { expectType } from 'ts-expect';  declare module '.\/file1' {   interface TypesConfiguration {     value: string;   } } \/\/ There's no error. The type is `string | undefined` expectType&lt;string | undefined>(value); \/\/ Error. The type is `string | undefined` expectType&lt;number | undefined>(value);<\/code><\/pre>\n<p>\u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e <code>| undefined<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f \u043c\u043e\u0433 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b, \u0442\u043e \u0442\u0438\u043f \u0443 <code>value<\/code> \u0431\u044b\u043b \u0431\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a\u043e\u0439 \u0431\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 <code>TypesConfiguration<\/code>.<\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/2\/conditional-types.html#handbook-content\" rel=\"noopener noreferrer nofollow\"><u>\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/u><\/a>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0435\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043e\u043b\u0431\u044d\u043a \u043d\u0430 \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043d\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e. \u0418\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u0430\u043a \u043f\u043e \u0444\u043b\u0430\u0433\u0443 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  \/\/ Typed by flag. If flag is not used, type is string, otherwise - number. `| undefined` is not necessary export const valueTypedByFlag: (TypesConfiguration extends {   useNumber: true } ? number : string) | undefined = undefined;  \/\/ Type must be set in the final product. If the type is not set, a fallback non-strict type is used export const mapTypedWithFallback: TypesConfiguration extends { mapTypedWithFallback: unknown } ? TypesConfiguration['mapTypedWithFallback'] : Record&lt;string, number> = {};  \/\/ =====================  \/\/ file2.ts import { value, map } from '.\/file1'; import { expectType } from 'ts-expect';  declare module '.\/file1' {   interface TypesConfiguration {     \/\/ If useNumber: true is not passed, the type of `value`     \/\/  will be string     useNumber: true;      \/\/ If `map` is not passed, we can use any key in the map.     \/\/  But now only `key1` and `key2` are accessible     mapTypedWithFallback: {       key1: 1,       key2: 2,     }   } }   \/\/ No error since useNumber: true is used expectType&lt;number | undefiend>(value);  \/\/ No error console.log(map, map.key1, map.key2);  \/\/ Error if `mapTypedWithFallback` is passed console.log(map.randomKey);<\/code><\/pre>\n<h2>\u041d\u043e \u0433\u0434\u0435 \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f?<\/h2>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 \u043a \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041d\u043e \u0432\u0430\u043c \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u043d\u0430\u043a\u0438\u0434\u0430\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438<\/h3>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u041a\u0430\u043a \u0438 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>useNumber<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>TypesConfiguration<\/code> \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u0435\u043d \u0437\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">\/\/ file1.ts export interface TypesConfiguration {}  export const decorator: TypesConfiguration extends { experimentalDecorators: true }   ? PropertyDecorator   : &lt;This, Value extends number>(_: unknown, context: ClassFieldDecoratorContext&lt;This, Value>) => void;  \/\/ file2.ts import { decorator } from '.\/file1';  declare module '.\/file1' {   interface TypesConfiguration {     \/\/ Must be set to<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-351107","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351107","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=351107"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351107\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}