{"id":287365,"date":"2018-08-16T14:07:41","date_gmt":"2018-08-16T10:07:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=287365"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=287365","title":{"rendered":"\u0412\u043e\u0439\u043d\u0430 \u0441 TypeScript \u0438\u043b\u0438 \u043f\u043e\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Enum"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/420041\/\" class=\"post__text post__text-html js-mediator-article\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>  \u041f\u043e\u043b \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0435 \u0438 \u043c\u043e\u0434\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0442\u0435\u043a\u043e\u043c, \u043d\u0430 \u0431\u0430\u0437\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0441\u0442 \u043a \u043b\u0435\u0433\u0430\u0441\u0438 \u043a\u043e\u0434\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u043b\u044c\u0441\u044b. \u041c\u043d\u0435 \u043f\u043e\u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u044d\u0442\u0443 \u0433\u0440\u0443\u043f\u043f\u0443. \u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 TypeScript. GUI \u043f\u043e\u0434\u043b\u043e\u0436\u043a\u0443 \u0440\u0435\u0448\u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 vue \u0432 \u043a\u0443\u043f\u0435 \u0441 <a href=\"https:\/\/github.com\/vuejs\/vue-class-component\">vue-class-component<\/a> \u0438 <a href=\"https:\/\/github.com\/thiagobustamante\/typescript-ioc\">IoC<\/a>.<\/p>\n<p>  \u041d\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043e\u0442 \u043b\u0435\u0433\u0430\u0441\u0438 \u043a\u043e\u0434\u0430, \u0430 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043b\u0438\u043b\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0432\u043e\u0439\u043d\u0443 \u0437\u043d\u0430\u043d\u0438\u0439. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439<\/h2>\n<p>  \u0421\u043f\u0443\u0441\u0442\u044f \u043f\u0430\u0440\u0443 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430, \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u0441\u0432\u043e\u0438\u043b\u0430\u0441\u044c \u0441 \u043d\u043e\u0432\u044b\u043c \u0441\u0442\u0435\u043a\u043e\u043c \u0438 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u043d\u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0431\u0440\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u0430\u0441\u0441\u0430 \u043c\u044f\u0441\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0434\u0443\u0445 \u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043a\u043e\u0434\u0438\u043b\u0438.<\/p>\n<p>  \u041c\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0439 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043a\u0430\u043a \u0412\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u0445\u0432\u0430\u0442\u0430\u043b\u043e. \u041d\u043e \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u0432\u0430\u0436\u043d\u043e\u0433\u043e, \u043f\u043e \u0438\u0440\u043e\u043d\u0438\u0438 \u0441\u0443\u0434\u044c\u0431\u044b, \u043c\u0435\u043d\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0446\u0435\u043f\u043b\u044f\u043b\u043e. \u041d\u0435 \u0446\u0435\u043f\u043b\u044f\u043b\u043e \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0410 \u0432\u043e\u0442 \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0435\u0432\u0430\u0436\u043d\u043e\u0433\u043e, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u043f\u043e\u043a\u043e\u044f. \u041c\u0435\u043d\u044f \u0434\u043e \u0431\u0435\u0437\u0443\u043c\u0438\u044f \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u043b\u043e \u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435. \u041d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0422\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0448\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442\u043e \u043d\u0430\u0439\u0434\u0435\u0448\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0433\u043e, \u0430 \u0442\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435\u0447\u0442\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u043e\u0435 \u0438 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435. \u0418 \u0432\u0438\u043d\u0438\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u043a\u043e\u0433\u043e. \u0422\u0435\u043c\u043f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u0434\u043b\u044f \u0438\u0437\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u043b\u0435\u0433\u0430\u0441\u0438 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u0435\u043b\u0438\u043a.<\/p>\n<p>  \u041f\u043e\u0434\u043d\u044f\u0432 \u0442\u0435\u043c\u0443 \u0441 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u043b\u043b\u0435\u0433, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u044f \u043d\u0435 \u0434\u043e\u0432\u043e\u043b\u0435\u043d \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438. \u0412 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043c\u043d\u0435 \u043f\u0440\u0438\u0432\u0438\u0434\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0437\u0430 \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u043a\u043e\u0434\u0438\u043d\u0433\u0430 \u044f \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u0432\u044b\u0437\u0432\u0430\u043b\u0441\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u041d\u043e \u043a\u0430\u043a \u044f \u0442\u043e\u0433\u0434\u0430 \u043e\u0448\u0438\u0431\u0430\u043b\u0441\u044f\u2026<\/p>\n<pre><code>\/\/ \u041c\u041e\u042f \u0424\u0410\u041d\u0422\u0410\u0417\u0418\u042f \u043d\u0430 \u0442\u0435\u043c\u0443, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438. import {Enum} from \"ts-jenum\";  @Enum(\"text\") export class State {      static readonly NEW = new State(\"New\");     static readonly ACTIVE = new State(\"Active\");     static readonly BLOCKED = new State(\"Blocked\");      private constructor(public text: string) {         super();     } }  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f console.log(\"\" + State.ACTIVE);        \/\/ Active console.log(\"\" + State.BLOCKED);       \/\/ Blocked console.log(State.values());           \/\/ [State.NEW, State.ACTIVE, State.BLOCKED] console.log(State.valueOf(\"New\"));     \/\/ State.NEW console.log(State.valueByName(\"NEW\")); \/\/ State.NEW console.log(State.ACTIVE.enumName);    \/\/ ACTIVE <\/code><\/pre>\n<p>  <\/p>\n<h2>1. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/h2>\n<p>  \u0421 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e: \u0432\u0437\u044f\u0442\u044c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 Java-\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435. \u041d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u0435\u043d\u0434\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438, \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u043d\u0435\u043f\u0440\u0438\u043d\u0443\u0436\u0434\u0435\u043d\u043d\u043e. \u041a\u043e\u0434\u0438\u043d\u0433 \u043d\u0435 \u043e\u0442\u043d\u044f\u043b \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u0438\u043a\u043e\u0432 \u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u043b, \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u044d\u0442\u043e: <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>export function Enum(idProperty?: string) {     \/\/ tslint:disable-next-line     return function &lt;T extends Function, V&gt;(target: T): T {         if ((target as any).__enumMap__ || (target as any).__enumValues__) {             const enumName = (target as any).prototype.constructor.name;             throw new Error(`The enumeration ${enumName} has already initialized`);         }         const enumMap: any = {};         const enumMapByName: any = {};         const enumValues = [];         \/\/ Lookup static fields         for (const key of Object.keys(target)) {             const value: any = (target as any)[key];             \/\/ Check static field: to be instance of enum type             if (value instanceof target) {                 let id;                 if (idProperty) {                     id = (value as any)[idProperty];                     if (typeof id !== \"string\" &amp;&amp; typeof id !== \"number\") {                         const enumName = (target as any).prototype.constructor.name;                         throw new Error(`The value of the ${idProperty} property in the enumeration element ${enumName}. ${key} is not a string or a number: ${id}`);                     }                 } else {                     id = key;                 }                 if (enumMap[id]) {                     const enumName = (target as any).prototype.constructor.name;                     throw new Error(`An element with the identifier ${id}: ${enumName}.${enumMap[id].enumName} already exists in the enumeration ${enumName}`);                 }                 enumMap[id] = value;                 enumMapByName[key] = value;                 enumValues.push(value);                 Object.defineProperty(value, \"__enumName__\", {value: key});                 Object.freeze(value);             }         }         Object.freeze(enumMap);         Object.freeze(enumValues);         Object.defineProperty(target, \"__enumMap__\", {value: enumMap});         Object.defineProperty(target, \"__enumMapByName__\", {value: enumMapByName});         Object.defineProperty(target, \"__enumValues__\", {value: enumValues});         if (idProperty) {             Object.defineProperty(target, \"__idPropertyName__\", {value: idProperty});         }         \/\/ \u043c\u0435\u0442\u043e\u0434\u044b values(), valueOf \u0438 \u0434\u0440 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438\u0441\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0436\u0438\u043b\u0438 \u0437\u0434\u0435\u0441\u044c \u043a\u043e\u0433\u0434\u0430-\u0442\u043e.         Object.freeze(target);         return target;     }; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0418 \u0437\u0434\u0435\u0441\u044c \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u0442\u0438\u0433\u043b\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u0430. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f. \u041d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0443 Microsoft \u0435\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435: <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/issues\/4881\">Class Decorator Mutation<\/a>. \u041a\u043e\u0433\u0434\u0430 \u044f \u0433\u043e\u0432\u043e\u0440\u044e, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f, \u044f \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0412\u0430\u0448\u0430 IDE \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0443\u0437\u043d\u0430\u0435\u0442 \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a \u0438 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u043d\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442. \u0410 \u0442\u0438\u043f \u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u043b\u043a\u0443 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e\u2026<\/p>\n<h2>2. \u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  \u041a\u0430\u043a \u044f \u043d\u0435 \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0443\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f, \u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0438\u0434\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u0430 \u0438 \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e? \u042f \u0431\u044b\u043b \u0440\u0430\u0437\u0434\u043e\u0441\u0430\u0434\u043e\u0432\u0430\u043d \u0441\u0430\u043c\u0438\u043c \u0441\u043e\u0431\u043e\u0439. \u0412\u0440\u0435\u043c\u044f \u0442\u043e \u0438\u0434\u0435\u0442, \u043f\u0430\u0440\u043d\u0438 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u0444\u0438\u0433\u0430\u0447\u0430\u0442 \u0434\u0430\u0439 \u0431\u043e\u0433, \u0430 \u044f \u0442\u0443\u0442 \u043d\u0430 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u0440\u0435\u043c\u044f \u0442\u0440\u0430\u0447\u0443. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430 \u0447\u0430\u0441 \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c enum \u0438 \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435. \u0417\u043d\u0430\u0447\u0438\u0442 \u0442\u0430\u043a \u0442\u043e\u043c\u0443 \u0438 \u0431\u044b\u0442\u044c. \u0411\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u043a\u0438\u0434\u0430\u043b \u043a\u043e\u0434 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Enumerable \u0438 \u0432\u0437\u0434\u043e\u0445\u043d\u0443\u043b, \u043f\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u043e\u0432\u0430\u0432 \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u0435. \u0417\u0430\u043a\u0438\u043d\u0443\u043b \u0434\u0440\u0430\u0444\u0442 \u0432 \u043e\u0431\u0449\u0438\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u043a\u043e\u043b\u043b\u0435\u0433\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Enumerable<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>\/\/ \u041f\u0420\u0418\u041c\u0415\u0427\u0410\u041d\u0418\u0415: \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b, \u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u044f \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u043b export class Enumerable&lt;T&gt; {      constructor() {         const clazz = this.constructor as any as EnumStore;         if (clazz.__enumMap__ || clazz.__enumValues__ || clazz.__enumMapByName__) {             throw new Error(`It is forbidden to create ${clazz.name} enumeration elements outside the enumeration`);         }     }      static values&lt;T&gt;(): ReadonlyArray&lt;T&gt; {         const clazz = this as any as EnumStore;         if (!clazz.__enumValues__) {             throw new Error(`${clazz.name} enumeration has not been initialized. It is necessary to add the decorator @Enum to the class`);         }         return clazz.__enumValues__;     }      static valueOf&lt;T&gt;(id: string | number): T {         const clazz = this as any as EnumStore;         if (!clazz.__enumMap__) {             throw new Error(`${clazz.name} enumeration has not been initialized. It is necessary to add the decorator @Enum to the class`);         }         const value = clazz.__enumMap__[id];         if (!value) {             throw new Error(`The element with ${id} identifier does not exist in the $ {clazz.name} enumeration`);         }         return value;     }      static valueByName&lt;T&gt;(name: string): T {         const clazz = this as any as EnumStore;         if (!clazz.__enumMapByName__) {             throw new Error(`${clazz.name} enumeration has not been initialized. It is necessary to add the decorator @Enum to the class`);         }         const value = clazz.__enumMapByName__[name];         if (!value) {             throw new Error(`The element with ${name} name does not exist in the ${clazz.name} enumeration`);         }         return value;     }      get enumName(): string {         return (this as any).__enumName__;     }      toString(): string {         const clazz = this.constructor as any as EnumStore;         if (clazz.__idPropertyName__) {             const self = this as any;             return self[clazz.__idPropertyName__];         }         return this.enumName;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041d\u043e \u0442\u0440\u0430\u0433\u0438\u043a\u043e\u043c\u0435\u0434\u0438\u044f \u043d\u0430\u0431\u0438\u0440\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u0445\u043e\u0434. \u0423 \u043c\u0435\u043d\u044f \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d TypeScript \u0432\u0435\u0440\u0441\u0438\u0438 2.6.2, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u043c\u0435\u043b\u0441\u044f \u0431\u0435\u0441\u0446\u0435\u043d\u043d\u044b\u0439 \u0431\u0430\u0433. \u0411\u0435\u0441\u0446\u0435\u043d\u043d\u044b\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0431\u0430\u0433, \u0430 \u0444\u0438\u0442\u0447\u0430. \u0413\u043e\u043b\u043e\u0441 \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u043d\u0430\u0442\u044b \u043f\u0440\u043e\u043a\u0440\u0438\u0447\u0430\u043b, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f. \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 (<i>\u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/i>). \u042f \u043d\u0435 \u043f\u043e\u0432\u0435\u0440\u0438\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0443\u0448\u0430\u043c, \u0438\u0431\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u043f\u0440\u043e\u0435\u043a\u0442, \u043f\u0435\u0440\u0435\u0434 \u043f\u0443\u0448\u0435\u043c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0434\u0440\u0430\u0444\u0442. \u0410 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0433\u043e\u043b\u043e\u0441 \u043f\u0440\u043e\u0448\u0435\u043f\u0442\u0430\u043b: \u044d\u0442\u043e \u0444\u0438\u0430\u0441\u043a\u043e, \u0431\u0440\u0430\u0442\u0430\u043d.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0434\u043e\u043b\u0433\u0438\u0445 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 TypeScript. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0438\u043c\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b \u044d\u0442\u043e \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0442\u0438\u043f. \u041d\u043e \u043a\u0430\u043a \u0431\u044b \u0442\u0430\u043c \u043d\u0435 \u0431\u044b\u043b\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u0443\u0436\u0435 \u0447\u0430\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u043e\u0439 \u0432\u043e\u0439\u043d\u044b \u0437\u0430 \u0437\u043d\u0430\u043d\u0438\u0435 TypeScript.<\/p>\n<p>  \u0412 \u0441\u0443\u0445\u043e\u043c \u043e\u0441\u0442\u0430\u0442\u043a\u0435: \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u0430\u043a \u0431\u044b\u043b\u0430 \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c. \u041c\u043e\u044f \u043f\u0435\u0447\u0430\u043b\u044c\u2026<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: <i>\u043d\u0435 \u043c\u043e\u0433\u0443 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443 \u0441\u0435\u0431\u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u0441 2.6.2, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043e\u0448\u0438\u0431\u0441\u044f \u0438\u043b\u0438 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0434\u043e\u043f\u0438\u0441\u0430\u043b \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445. \u0410 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/issues\/24018\">Allow static members to reference class type parameters<\/a> \u0431\u044b\u043b \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d.<\/i><\/p>\n<h2>3. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u0440\u0438\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043b\u043e\u0441\u044c, \u0441 \u044f\u0432\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a, State.valueOf&lt;State&gt;(), \u043e\u043d\u043e \u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e \u0438 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u0435\u043d\u044f. \u041d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0434\u0430\u0436\u0435 \u043e\u0442\u043b\u043e\u0436\u0438\u043b \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0434\u043e\u043b\u0431\u0430\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u043b \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u043c\u043e\u0433\u0443 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>  \u041c\u043e\u0440\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u0441\u0438\u043b\u044b, \u044f \u043f\u043e\u0440\u044b\u0441\u043a\u0430\u043b \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0442\u0440\u044e\u043a\u0438 \u0441 TypeScript, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043a\u0442\u043e \u043e\u0442 \u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442, \u043f\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043f\u043e \u044f\u0437\u044b\u043a\u0443 \u0435\u0449\u0435 \u0440\u0430\u0437, \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438 \u0440\u0435\u0448\u0438\u043b, \u0432\u043e \u0447\u0442\u043e\u0431\u044b \u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043b\u043e, \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u0435\u043b\u043e \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0421\u0435\u043c\u044c \u0447\u0430\u0441\u043e\u0432 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0435 \u043e\u0442\u0440\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e, \u0434\u0430\u0436\u0435 \u043d\u0430 \u043a\u043e\u0444\u0435, \u0434\u0430\u043b\u0438 \u0441\u0432\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430, \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u0432\u0441\u0435 \u043d\u0430 \u0441\u0432\u043e\u0438 \u043c\u0435\u0441\u0442\u0430.<\/p>\n<pre><code>export function EnumType&lt;T&gt;(): IStaticEnum&lt;T&gt; {     return (&lt;IStaticEnum&lt;T&gt;&gt; Enumerable); } \/\/ \u0433\u0434\u0435 IStaticEnum \u044d\u0442\u043e: export interface IStaticEnum&lt;T&gt; {      new(): {enumName: string};      values(): ReadonlyArray&lt;T&gt;;      valueOf(id: string | number): T;      valueByName(name: string): T; }  <\/code><\/pre>\n<p>  \u0410 \u0441\u0430\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 Java-\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>import {Enum, EnumType, IStaticEnum} from \"ts-jenum\";  @Enum(\"text\") export class State extends EnumType&lt;State&gt;() {      static readonly NEW = new State(\"New\");     static readonly ACTIVE = new State(\"Active\");     static readonly BLOCKED = new State(\"Blocked\");      private constructor(public text: string) {         super();     } }  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f console.log(\"\" + State.ACTIVE);        \/\/ Active console.log(\"\" + State.BLOCKED);       \/\/ Blocked console.log(State.values());           \/\/ [State.NEW, State.ACTIVE, State.BLOCKED] console.log(State.valueOf(\"New\"));     \/\/ State.NEW console.log(State.valueByName(\"NEW\")); \/\/ State.NEW console.log(State.ACTIVE.enumName);    \/\/ ACTIVE <\/code><\/pre>\n<p>  \u041d\u0435 \u043e\u0431\u043e\u0448\u043b\u043e\u0441\u044c \u0438 \u0431\u0435\u0437 \u043a\u0443\u0440\u044c\u0435\u0437\u0430, \u0441 \u043b\u0438\u0448\u043d\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u043c IStaticEnum, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f (\u0441\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435). \u0412 \u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0437\u043b\u043e\u043f\u043e\u043b\u0443\u0447\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 TypeScript 2.6.2 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u044f\u0432\u043d\u043e. \u0411\u0430\u0433 \u043d\u0430 \u0442\u0435\u043c\u0443 <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\/issues\/15870\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u0434\u043e\u043b\u0433\u043e \u043c\u0443\u0447\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b <a href=\"https:\/\/github.com\/reforms\/ts-jenum\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043e\u0442\u043a\u0440\u044b\u043b, \u0447\u0442\u043e TypeScript \u2014 \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u042d\u0442\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0442\u043e\u043d\u0443\u0442\u044c. \u0410 \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0438\u0434\u0442\u0438 \u043a\u043e \u0434\u043d\u0443, \u0443\u0447\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/LMFinney\/ts-enums\">Enum \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/UselessPickles\/ts-enum-util\">\u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438<\/a><\/li>\n<\/ul>\n<p>  \u041f\u0438\u0448\u0438\u0442\u0435 \u043e \u0441\u0432\u043e\u0438\u0445 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u0445, \u0434\u0443\u043c\u0430\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441.<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <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\/post\/420041\/\"> https:\/\/habr.com\/post\/420041\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/420041\/\" class=\"post__text post__text-html js-mediator-article\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>  \u041f\u043e\u043b \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0435 \u0438 \u043c\u043e\u0434\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0442\u0435\u043a\u043e\u043c, \u043d\u0430 \u0431\u0430\u0437\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0441\u0442 \u043a \u043b\u0435\u0433\u0430\u0441\u0438 \u043a\u043e\u0434\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u043b\u044c\u0441\u044b. \u041c\u043d\u0435 \u043f\u043e\u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u044d\u0442\u0443 \u0433\u0440\u0443\u043f\u043f\u0443. \u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 TypeScript. GUI \u043f\u043e\u0434\u043b\u043e\u0436\u043a\u0443 \u0440\u0435\u0448\u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 vue \u0432 \u043a\u0443\u043f\u0435 \u0441 <a href=\"https:\/\/github.com\/vuejs\/vue-class-component\">vue-class-component<\/a> \u0438 <a href=\"https:\/\/github.com\/thiagobustamante\/typescript-ioc\">IoC<\/a>.<\/p>\n<p>  \u041d\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043e\u0442 \u043b\u0435\u0433\u0430\u0441\u0438 \u043a\u043e\u0434\u0430, \u0430 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043b\u0438\u043b\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0432\u043e\u0439\u043d\u0443 \u0437\u043d\u0430\u043d\u0438\u0439. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-287365","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287365","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=287365"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287365\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}