diff --git a/dist/index.html b/dist/index.html
new file mode 100644
index 0000000..f740093
--- /dev/null
+++ b/dist/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+ Заголовок
+
+
+
+
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
deleted file mode 100644
index c6a18e7..0000000
--- a/package-lock.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "ts-task-1",
- "version": "1.0.0",
- "lockfileVersion": 1,
- "requires": true,
- "dependencies": {
- "tsc": {
- "version": "1.20150623.0",
- "resolved": "https://registry.npmjs.org/tsc/-/tsc-1.20150623.0.tgz",
- "integrity": "sha1-Trw8d04WkUjLx2inNCUz8ILHpuU="
- }
- }
-}
diff --git a/package.json b/package.json
deleted file mode 100644
index 0d703f8..0000000
--- a/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "ts-task-1",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
- "start": "npx tsc src/**/*.ts"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/RTF-Angular-2021/ts-task-1.git"
- },
- "author": "",
- "license": "ISC",
- "bugs": {
- "url": "https://github.com/RTF-Angular-2021/ts-task-1/issues"
- },
- "homepage": "https://github.com/RTF-Angular-2021/ts-task-1#readme",
- "dependencies": {
- "tsc": "^1.20150623.0"
- },
- "devDependencies": {}
-}
diff --git a/src/index.html b/src/index.html
new file mode 100644
index 0000000..f740093
--- /dev/null
+++ b/src/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+ Заголовок
+
+
+
+
+
\ No newline at end of file
diff --git a/src/task_1/app.ts b/src/task_1/app.ts
new file mode 100644
index 0000000..f09d031
--- /dev/null
+++ b/src/task_1/app.ts
@@ -0,0 +1,5 @@
+namespace Custom {
+ let user = new User(5, 'Max');
+ user.upAgeByYear();
+ console.log(user);
+}
diff --git a/src/task_1/typing.d.ts b/src/task_1/typing.d.ts
new file mode 100644
index 0000000..0e181b9
--- /dev/null
+++ b/src/task_1/typing.d.ts
@@ -0,0 +1,9 @@
+declare namespace Custom {
+ class User {
+ public age: number;
+ public name: string;
+ constructor(a: number, n: string);
+ public upAgeByYear(): void;
+ }
+ let user: User;
+}
\ No newline at end of file
diff --git a/src/task_2/example.ts b/src/task_2/example.ts
new file mode 100644
index 0000000..1e9de7a
--- /dev/null
+++ b/src/task_2/example.ts
@@ -0,0 +1,11 @@
+import { Setting } from './setting'
+
+export class Example {
+ public title: string;
+ public id: number;
+ private _setting: Setting;
+
+ constructor(s: Setting) {
+ this._setting = s;
+ }
+}
\ No newline at end of file
diff --git a/src/task_2/index.ts b/src/task_2/index.ts
index a2fa801..769d672 100644
--- a/src/task_2/index.ts
+++ b/src/task_2/index.ts
@@ -6,33 +6,18 @@
* все остальные файлы должны подгрузиться асинхронно по цепочке, используя requireJS.
*/
-class SettingValue {
- public property1: string;
- public property2: string;
-
- constructor(p1: string, p2: string) {
- this.property1 = p1;
- this.property2 = p2;
- }
-}
-
-class Setting {
- public key: string;
- public value: SettingValue;
-
- constructor(k: string, ov: SettingValue) {
- this.key = k;
- this.value = ov;
- }
-}
-
-
-class Example {
- public title: string;
- public id: number;
- private _setting: Setting;
-
- constructor(s: Setting) {
- this._setting = s;
+import { Example } from './example';
+import { Setting } from './setting';
+import { SettingValue } from './setting-value';
+
+class Test {
+ public print(a: string, b: number): string {
+ return `${a} and ${b}`;
}
}
+
+let test = new Test();
+const example = new Example(new Setting("test", new SettingValue("test", "test")));
+example.id = 5;
+example.title = "test";
+console.log(test.print(example.title, example.id));
\ No newline at end of file
diff --git a/src/task_2/setting-value.ts b/src/task_2/setting-value.ts
new file mode 100644
index 0000000..3b52468
--- /dev/null
+++ b/src/task_2/setting-value.ts
@@ -0,0 +1,9 @@
+export class SettingValue {
+ public property1: string;
+ public property2: string;
+
+ constructor(p1: string, p2: string) {
+ this.property1 = p1;
+ this.property2 = p2;
+ }
+}
\ No newline at end of file
diff --git a/src/task_2/setting.ts b/src/task_2/setting.ts
new file mode 100644
index 0000000..a59baa9
--- /dev/null
+++ b/src/task_2/setting.ts
@@ -0,0 +1,11 @@
+import { SettingValue } from './setting-value'
+
+export class Setting {
+ public key: string;
+ public value: SettingValue;
+
+ constructor(k: string, ov: SettingValue) {
+ this.key = k;
+ this.value = ov;
+ }
+}
\ No newline at end of file
diff --git a/src/task_3/index.ts b/src/task_3/index.ts
index 04eaab2..0fa4cf5 100644
--- a/src/task_3/index.ts
+++ b/src/task_3/index.ts
@@ -16,33 +16,30 @@ class HttpError extends Error {
}
}
-function req(url: string): Promise {
- return fetch(url)
- .then((response: Response) => {
- if (response.status == 200) {
- return response.json();
- } else {
- throw new HttpError(response);
- }
- })
+async function req(url: string): Promise {
+ const response: Response = await fetch(url);
+ if (response.status == 200) {
+ return response.json();
+ } else {
+ throw new HttpError(response);
+ }
}
// Запрашивать логин, пока github не вернёт существующего пользователя.
-function getGitHub() {
+async function getGitHub() {
let name = prompt("Введите логин на GitHub?", "");
-
- return req(`https://api.github.com/users/${name}`)
- .then(user => {
- document.write(`Полное имя: ${user.name}, уникальный номер: ${user.id}.`);
- return user;
- })
- .catch(err => {
- if (err instanceof HttpError && err.response.status == 404) {
- document.write("Такого пользователя не существует.");
- } else {
- throw err;
- }
- });
+ let user;
+ try {
+ user = await req(`https://api.github.com/users/${name}`);
+ document.write(`Полное имя: ${user.name}, уникальный номер: ${user.id}.`);
+ return user;
+ } catch(err) {
+ if (err instanceof HttpError && err.response.status == 404) {
+ document.write("Такого пользователя не существует.");
+ } else {
+ throw err;
+ }
+ }
}
getGitHub();
diff --git a/src/task_4/index.ts b/src/task_4/index.ts
index 9f25e4b..33b66b2 100644
--- a/src/task_4/index.ts
+++ b/src/task_4/index.ts
@@ -3,4 +3,4 @@
* Использовать: https://docs.github.com/en/rest/reference/git#create-a-blob
* Не забывайте, что пригодится аутентификация и ключ:
* https://docs.github.com/en/developers/apps/authenticating-with-github-apps#authenticating-as-an-installation
-*/
\ No newline at end of file
+*/
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..d2edbf3
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "traceResolution": false,
+ "experimentalDecorators": true,
+ "noImplicitAny": false,
+ "noEmitOnError": true,
+ "removeComments": false,
+ "sourceMap": true,
+ "moduleResolution": "node",
+ "module": "amd",
+ "target": "ES6",
+ "outDir": "dist"
+ },
+ "include": [
+ "src/**/*"]
+ }
\ No newline at end of file