From b29bdd31a3b3944c7416354ba9775b7a2ca91084 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Fri, 15 Nov 2024 18:47:32 +0300 Subject: [PATCH] readme files --- 05_error/Readme.md | 25 +++++++++++++++++++++++++ 05_error/animals.js | 40 ---------------------------------------- 2 files changed, 25 insertions(+), 40 deletions(-) create mode 100644 05_error/Readme.md delete mode 100644 05_error/animals.js diff --git a/05_error/Readme.md b/05_error/Readme.md new file mode 100644 index 0000000..dfa5468 --- /dev/null +++ b/05_error/Readme.md @@ -0,0 +1,25 @@ +# Ошибки + +> Откройте [пример](./animals.ts) + +* запустите typesscript + +```shell +tsc +``` + +> Запустите полученный javascript файл + +```shell +node ./animal.js +``` + +> Обратите внимание на ошибку при запуске + +![ts error](../assets/05.png) + +> Определите почему именно возникла ошибка + +> Обратите внимание что typescript не указал на ошибку до runtime + +[Полезные ссылки](./links.md) diff --git a/05_error/animals.js b/05_error/animals.js deleted file mode 100644 index b9a93e3..0000000 --- a/05_error/animals.js +++ /dev/null @@ -1,40 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var Animal = /** @class */ (function () { - function Animal() { - } - return Animal; -}()); -var Dog = /** @class */ (function (_super) { - __extends(Dog, _super); - function Dog() { - return _super !== null && _super.apply(this, arguments) || this; - } - Dog.prototype.bark = function () { }; - return Dog; -}(Animal)); -var Cat = /** @class */ (function (_super) { - __extends(Cat, _super); - function Cat() { - return _super !== null && _super.apply(this, arguments) || this; - } - Cat.prototype.meow = function () { }; - return Cat; -}(Animal)); -var cage1 = [new Dog(), new Dog()]; -var cage2 = cage1; // ok -cage2.push(new Cat()); // ok -cage1.forEach(function (dog) { return dog.bark(); }); // ok