Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Заголовок</title>
</head>
<body>
<script data-main="../dist/task_2/index.js"
src="https://requirejs.org/docs/release/2.3.6/minified/require.js"></script>
</body>
</html>
13 changes: 0 additions & 13 deletions package-lock.json

This file was deleted.

24 changes: 0 additions & 24 deletions package.json

This file was deleted.

11 changes: 11 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Заголовок</title>
</head>
<body>
<script data-main="../dist/task_2/index.js"
src="https://requirejs.org/docs/release/2.3.6/minified/require.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions src/task_1/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Custom {
let user = new User(5, 'Max');
user.upAgeByYear();
console.log(user);
}
9 changes: 9 additions & 0 deletions src/task_1/typing.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не будет работать в браузере. Нужно написать тайпинг к JS который указан в index.html файле

11 changes: 11 additions & 0 deletions src/task_2/example.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
41 changes: 13 additions & 28 deletions src/task_2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
9 changes: 9 additions & 0 deletions src/task_2/setting-value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class SettingValue {
public property1: string;
public property2: string;

constructor(p1: string, p2: string) {
this.property1 = p1;
this.property2 = p2;
}
}
11 changes: 11 additions & 0 deletions src/task_2/setting.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

правильно 3 бала

43 changes: 20 additions & 23 deletions src/task_3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,30 @@ class HttpError extends Error {
}
}

function req(url: string): Promise<IUser> {
return fetch(url)
.then((response: Response) => {
if (response.status == 200) {
return response.json();
} else {
throw new HttpError(response);
}
})
async function req(url: string): Promise<IUser> {
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;
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 бала

getGitHub();
2 changes: 1 addition & 1 deletion src/task_4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
*/
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}