Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function overloads lesson #109

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/20-functions/85-function-overloads/description.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ theory: |
function concat(a: number, b: number): string;
function concat(a: string, b: string): string;

function concat(a: unknown, b: unknown): string {
function concat(a: any, b: any): string {
if (typeof a === 'string') {
return `${a}{b}`;
return `${a}${b}`;
} else {
return `${a.toFixed()}${b.toFixed()}`;
}
Expand All @@ -32,11 +32,11 @@ theory: |

```typescript
function add(a: number, b: number, c: number): number;
function add(a: number, b: number): unknown;
function add(a: string, b: string): unknown;
function add(a: number, b: number): number;
function add(a: string, b: string): string;

// Сигнатура подходит под все примеры выше
function add(a: unknown, b: unknown, c?: unknown): unknown {
function add(a: any, b: any, c?: number): unknown {
// тут вся логика
if (c === undefined) {
// ...
Expand Down
4 changes: 2 additions & 2 deletions modules/20-functions/90-type-narrowing/description.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ theory: |
function concat(a: number, b: number): string;
function concat(a: string, b: string): string;

function concat(a: unknown, b: unknown): string {
if (typeof a == 'string') {
function concat(a: any, b: any): string {
if (typeof a === 'string') {
return `${a}${b}`;
// ^? (parameter) a: string
} else {
Expand Down