Skip to content
Draft
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
5,034 changes: 5,034 additions & 0 deletions README-be_BY.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This book has been translated into several language versions, including:

[Italian](https://github.com/gibbok/typescript-book/blob/main/README-it_IT.md)

[Belarusian](https://github.com/gibbok/typescript-book/blob/main/README-be_BY.md)

## Downloads and website

You can also download the Epub version:
Expand Down
Binary file added downloads/typescript-book-be_BY.epub
Binary file not shown.
Binary file added downloads/typescript-book-be_BY.pdf
Binary file not shown.
Binary file modified downloads/typescript-book-it_IT.epub
Binary file not shown.
Binary file modified downloads/typescript-book-it_IT.pdf
Binary file not shown.
Binary file modified downloads/typescript-book-zh_CN.epub
Binary file not shown.
Binary file modified downloads/typescript-book-zh_CN.pdf
Binary file not shown.
Binary file modified downloads/typescript-book.epub
Binary file not shown.
Binary file modified downloads/typescript-book.pdf
Binary file not shown.
5 changes: 3 additions & 2 deletions tools/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export enum Language {
en_EN = 'en_EN',
zh_CN = 'zh_CN',
it_IT = 'it_IT',
be_BY = 'be_BY',
}
export type Languages = [Language.en_EN, Language.zh_CN, Language.it_IT]
export type Languages = [Language.en_EN, Language.zh_CN, Language.it_IT, Language.be_BY]

export const languages: Languages = [Language.en_EN, Language.zh_CN, Language.it_IT]
export const languages: Languages = [Language.en_EN, Language.zh_CN, Language.it_IT, Language.be_BY]
8 changes: 7 additions & 1 deletion tools/make-books.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ DIR_DOWNLOADS="downloads"
INPUT_EN="README"
INPUT_CN="README-zh_CN"
INPUT_IT="README-it_IT"
INPUT_BE="README-be_BY"

OUTPUT_EN="typescript-book"
OUTPUT_CN="typescript-book-zh_CN"
OUTPUT_IT="typescript-book-it_IT"
OUTPUT_BE="typescript-book-be_BY"

AUTHOR="Simone Poggiali"
TITLE_EN="The Concise TypeScript Book"
TITLE_CN="# 简洁的TypeScript之书"
TITLE_IT="The Concise TypeScript Book"
TITLE_BE="Лаканічная кніга па TypeScript"

cd ../

Expand Down Expand Up @@ -45,15 +48,18 @@ fi
pandoc -o $DIR_DOWNLOADS/$OUTPUT_EN.epub --metadata title="$TITLE_EN" --metadata author="$AUTHOR" -s $INPUT_EN.md
pandoc -o $DIR_DOWNLOADS/$OUTPUT_CN.epub --metadata title="$TITLE_CN" --metadata author="$AUTHOR" -s $INPUT_CN.md
pandoc -o $DIR_DOWNLOADS/$OUTPUT_IT.epub --metadata title="$TITLE_IT" --metadata author="$AUTHOR" -s $INPUT_IT.md
pandoc -o $DIR_DOWNLOADS/$OUTPUT_BE.epub --metadata title="$TITLE_BE" --metadata author="$AUTHOR" -s $INPUT_BE.md

# Validate eBooks
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
epubcheck $DIR_DOWNLOADS/$OUTPUT_IT.epub
epubcheck $DIR_DOWNLOADS/$OUTPUT_BE.epub

# Generate PDFs
ebook-convert $DIR_DOWNLOADS/$OUTPUT_EN.epub $DIR_DOWNLOADS/$OUTPUT_EN.pdf --pdf-page-numbers
ebook-convert $DIR_DOWNLOADS/$OUTPUT_CN.epub $DIR_DOWNLOADS/$OUTPUT_CN.pdf --pdf-page-numbers
ebook-convert $DIR_DOWNLOADS/$OUTPUT_IT.epub $DIR_DOWNLOADS/$OUTPUT_IT.pdf --pdf-page-numbers
ebook-convert $DIR_DOWNLOADS/$OUTPUT_BE.epub $DIR_DOWNLOADS/$OUTPUT_BE.pdf --pdf-page-numbers

echo "Books were created. Please commit!"
echo "Books were created. Please commit!"
8 changes: 6 additions & 2 deletions tools/make-website-content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Generate multiple Markdown documents from a single Markdown file by splitting it based on headings.
Generate multiple Markdown documents from a single Markdown file by splitting it based on headings.
This script is designed for creating pages on a website and provides results for multiple languages.
Note: the number of headings per language must be the same.
"""
Expand All @@ -9,7 +9,6 @@
import shutil
from typing import List


# INPUT_FILE_PATH = "./test-md/README.md"
# OUTPUT_DIR_PATH = "./test-md/en"
# INPUT_FILE_PATH_CN = "./test-md/README-zh_CN.md"
Expand All @@ -24,6 +23,9 @@
INPUT_FILE_PATH_IT = "../README-it_IT.md"
OUTPUT_DIR_PATH_IT = "../website/src/content/docs/it-it/book"

INPUT_FILE_PATH_BE = "../README-be_BY.md"
OUTPUT_DIR_PATH_BE = "../website/src/content/docs/be-by/book"


def manage_output_dir(path: str) -> None:
if os.path.exists(path):
Expand Down Expand Up @@ -146,3 +148,5 @@ def process(base_input_path, input_lang_path: str, base_output_path: str) -> Non
process(INPUT_FILE_PATH, INPUT_FILE_PATH_CN, OUTPUT_DIR_PATH_CN)

process(INPUT_FILE_PATH, INPUT_FILE_PATH_IT, OUTPUT_DIR_PATH_IT)

process(INPUT_FILE_PATH, INPUT_FILE_PATH_BE, OUTPUT_DIR_PATH_BE)
4 changes: 3 additions & 1 deletion tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions website/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export default defineConfig({
label: 'Italiano',
lang: 'it-IT',
},
'be-by': {
label: 'Беларуская',
lang: 'be-BY',
},
},
sidebar: [
{
Expand Down
17 changes: 17 additions & 0 deletions website/src/content/docs/be-by/book/about-the-author.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: About the Author
sidebar:
order: 6
label: 6. About the Author
---


Simone Poggiali is an experienced Staff Engineer with a passion for writing professional-grade code since the 90s. Throughout his international career, he has contributed to numerous projects for a wide range of clients, from startups to large organizations. Notable companies such as HelloFresh, Siemens, O2, Leroy Merlin and Snowplow have benefited from his expertise and dedication.

You can reach Simone Poggiali on the following platforms:

* LinkedIn: [https://www.linkedin.com/in/simone-poggiali](https://www.linkedin.com/in/simone-poggiali)
* GitHub: [https://github.com/gibbok](https://github.com/gibbok)
* X.com: [https://x.com/gibbok_coding](https://x.com/gibbok_coding)
* Email: gibbok.coding📧gmail.com

22 changes: 22 additions & 0 deletions website/src/content/docs/be-by/book/any-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Any type
sidebar:
order: 44
label: 44. Any type
---


The `any` type is a special type (universal supertype) that can be used to represent any type of value (primitives, objects, arrays, functions, errors, symbols). It is often used in situations where the type of a value is not known at compile time, or when working with values from external APIs or libraries that do not have TypeScript typings.

By utilizing `any` type, you are indicating to the TypeScript compiler that values should be represented without any limitations. In order to maximizing type safety in your code consider the following:

* Limit the usage of `any` to specific cases where the type is truly unknown.
* Do not return `any` types from a function as you will lose type safety in the code using that function weakening your type safety.
* Instead of `any` use `@ts-ignore` if you need to silence the compiler.

```typescript
let value: any;
value = true; // Valid
value = 7; // Valid
```

22 changes: 22 additions & 0 deletions website/src/content/docs/be-by/book/assignments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Assignments
sidebar:
order: 21
label: 21. Assignments
---


TypeScript narrowing using assignments is a way to narrow the type of a variable based on the value assigned to it. When a variable is assigned a value, TypeScript infers its type based on the assigned value, and it narrows the type of the variable to match the inferred type.

```typescript
let value: string | number;
value = 'hello';
if (typeof value === 'string') {
console.log(value.toUpperCase());
}
value = 42;
if (typeof value === 'number') {
console.log(value.toFixed(2));
}
```

21 changes: 21 additions & 0 deletions website/src/content/docs/be-by/book/built-in-type-primitives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Built-in Type Primitives
sidebar:
order: 49
label: 49. Built-in Type Primitives
---


TypeScript has several built-in type primitives that can be used to define variables, function parameters, and return types:

* `number`: Represents numeric values, including integers and floating-point numbers.
* `string`: Represents textual data
* `boolean`: Represents logical values, which can be either true or false.
* `null`: Represents the absence of a value.
* `undefined`: Represents a value that has not been assigned or has not been defined.
* `symbol`: Represents a unique identifier. Symbols are typically used as keys for object properties.
* `bigint`: Represents arbitrary-precision integers.
* `any`: Represents a dynamic or unknown type. Variables of type any can hold values of any type, and they bypass type checking.
* `void`: Represents the absence of any type. It is commonly used as the return type of functions that do not return a value.
* `never`: Represents a type for values that never occur. It is typically used as the return type of functions that throw an error or enter an infinite loop.

Loading