Skip to content

Commit 3e6f46c

Browse files
committed
2 parents 7d4f650 + 08b6a00 commit 3e6f46c

13 files changed

+916
-35
lines changed

.github/CODEOWNER renamed to .github/CODEOWNERS

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# See https://github.com/OSS-Docs-Tools/code-owner-self-merge#readme
22

33
# Collaborators for Japanese Translation of the Website
4-
docs/playground/ja @sasurau4 @Quramy @Naturalclar @Takepepe [translation] [jp]
5-
docs/tsconfig/ja/**/*.md @sasurau4 @Quramy @Naturalclar @Takepepe [translation] [jp]
6-
docs/typescriptlang/ja/**/*.ts @sasurau4 @Quramy @Naturalclar @Takepepe [translation] [jp]
7-
docs/typescriptlang/ja.ts @sasurau4 @Quramy @Naturalclar @Takepepe [translation] [jp]
8-
docs/documentation/ja/**/*.md @sasurau4 @Quramy @Naturalclar @Takepepe [translation] [jp]
4+
docs/playground/ja @sasurau4 @Quramy @Naturalclar [translation] [jp]
5+
docs/tsconfig/ja/**/*.md @sasurau4 @Quramy @Naturalclar [translation] [jp]
6+
docs/typescriptlang/ja/**/*.ts @sasurau4 @Quramy @Naturalclar [translation] [jp]
7+
docs/typescriptlang/ja.ts @sasurau4 @Quramy @Naturalclar [translation] [jp]
8+
docs/documentation/ja/**/*.md @sasurau4 @Quramy @Naturalclar [translation] [jp]
99

1010
# Collaborators for Portuguese Translation of the Website
1111
docs/playground/pt @khaosdoctor @danilofuchs [translation] [pt]
@@ -29,11 +29,11 @@ docs/typescriptlang/zh.ts @Kingwl [translation] [zh]
2929
docs/documentation/zh/**/*.md @Kingwl [translation] [zh]
3030

3131
# Collaborators for Korean Translation of the Website
32-
docs/playground/ko @Bumkeyy [translation] [ko]
33-
docs/tsconfig/ko/**/*.md @Bumkeyy [translation] [ko]
34-
docs/typescriptlang/ko/**/*.ts @Bumkeyy [translation] [ko]
35-
docs/typescriptlang/ko.ts @Bumkeyy [translation] [ko]
36-
docs/documentation/ko/**/*.md @Bumkeyy [translation] [ko]
32+
docs/playground/ko @Bumkeyy @yeonjuan @guyeol [translation] [ko]
33+
docs/tsconfig/ko/**/*.md @Bumkeyy @yeonjuan @guyeol [translation] [ko]
34+
docs/typescriptlang/ko/**/*.ts @Bumkeyy @yeonjuan @guyeol [translation] [ko]
35+
docs/typescriptlang/ko.ts @Bumkeyy @yeonjuan @guyeol [translation] [ko]
36+
docs/documentation/ko/**/*.md @Bumkeyy @yeonjuan @guyeol [translation] [ko]
3737

3838
# Collaborators for Indonesian Translation of the Website
3939
docs/playground/id @jefrydco @nusendra @mazipan @mandaputtra [translation] [id]
@@ -57,8 +57,8 @@ docs/typescriptlang/pl.ts @msieroslawska @TomWebwalker [translation] [pl]
5757
docs/documentation/pl/**/*.md @msieroslawska @TomWebwalker [translation] [pl]
5858

5959
# Collaborators for Italian Translation of the Website
60-
docs/playground/it @Nabster101 @BassDrop07 @PyGera [translation] [it]
61-
docs/tsconfig/it/**/*.md @Nabster101 @BassDrop07 @PyGera [translation] [it]
62-
docs/typescriptlang/it/**/*.ts @Nabster101 @BassDrop07 @PyGera [translation] [it]
63-
docs/typescriptlang/it.ts @Nabster101 @BassDrop07 @PyGera [translation] [it]
64-
docs/documentation/it/**/*.md @Nabster101 @BassDrop07 @PyGera [translation] [it]
60+
docs/playground/it @Nabster101 @DeltaPy @PyGera [translation] [it]
61+
docs/tsconfig/it/**/*.md @Nabster101 @DeltaPy @PyGera [translation] [it]
62+
docs/typescriptlang/it/**/*.ts @Nabster101 @DeltaPy @PyGera [translation] [it]
63+
docs/typescriptlang/it.ts @Nabster101 @DeltaPy @PyGera [translation] [it]
64+
docs/documentation/it/**/*.md @Nabster101 @DeltaPy @PyGera [translation] [it]

.github/workflows/codeowners-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Codeowners merging
22
on:
3-
pull_request_target: { types: opened }
3+
pull_request_target: { types: [ opened, synchronize, reopened] }
44
issue_comment: { types: created }
55
pull_request_review: { types: submitted }
66

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ yarn
1515
yarn pull-en
1616

1717
# Optional: Verify your changes will correctly replace the english files
18-
yarn validate-paths
18+
yarn lint
19+
# Alternative: Run the lint watcher
20+
yarn lint --watch
1921
```
2022

2123
That's it, you've got a copy of all the documentation and now can write documentation which follows the existing patterns.
@@ -46,7 +48,8 @@ For example if you wanted to translate a new handbook page you would:
4648
- Pull in the English files `yarn pull-en` (these will be gitignored)
4749
- Find your english file: `docs/documentation/en/handbook-v2/Basics.md`
4850
- Recreate the same folder path in your language: `docs/documentation/it/handbook-v2/Basics.md`
49-
- Translate the file!
51+
- Translate the file!
52+
- Validate your changes: `yarn lint` (or `yarn lint docs/documentation/it/handbook-v2/Basics.md`)
5053
- Create a pull request to this repo
5154
- Once merged, the translation will appear on the next website deploy
5255

@@ -56,12 +59,14 @@ When a new language is created, we ask for a few people to become language owner
5659

5760
The TypeScript team generally only know English, and can answer clarifying questions if needed! For quick questions, you can use the `ts-website-translation` channel in the [TypeScript Discord](https://discord.gg/typescript).
5861

59-
#### Well tested
62+
#### Secure
6063

6164
This repo has extensive CI to ensure that you can't accidentally break the TypeScript website.
6265

6366
There are local, fast checks that it won't break via `yarn test` and then the full TypeScript website test suite runs with the changes, and a website build is generated to ensure that nothing breaks.
6467

68+
The checks may not seem obvious to an outsider, because the website is complex, so there is a watch mode which you can run via `yarn link --watch` to get instant feedback.
69+
6570
# Contributing
6671

6772
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
display: "Iterazione di livello inferiore"
3+
oneline: "Emette Javascript compatibile e più dettagliato per oggetti iterativi"
4+
---
5+
6+
Iterazione di livello inferiore, o Downleveling, è un termine di TypeScript utilizzato per migrare verso una versione precedente di JavaScript. Questa flag permette quindi di supportare una più accurata implementazione di come il JavaScript moderno itera i nuovi concetti in versioni precedenti di JavaScript in runtime.
7+
8+
ECMAScript 6 aggiunge una serie di nuove iterazioni primitive: il `for / of` loop (`for (el of arr)`), spread di Array (`[a, ...b]`), spread di argomenti (`fn (... args)`) e [`Symbol.iterator`](https://medium.com/trainingcenter/iterators-em-javascript-880adef14495).`--downlevelIteration` permette a queste iterazioni primitive di essere utilizzate in modo più accurrato in un ambiente ES5 se un'implementazione di [`Symbol.iterator`](https://medium.com/trainingcenter/iterators-em-javascript-880adef14495) è presente.
9+
10+
#### Esempio: Effetti su `for / of`
11+
12+
Con questo codice TypeScript:
13+
14+
```js
15+
const str = "Ciao!";
16+
for (const s of str) {
17+
console.log(s);
18+
}
19+
```
20+
21+
Senza `downlevelIteration` attivo, un loop `for / of` su un qualsiasi oggetto viene convertito in un tradizionale `for` loop:
22+
23+
```ts twoslash
24+
// @target: ES5
25+
// @showEmit
26+
const str = "Ciao!";
27+
for (const s of str) {
28+
console.log(s);
29+
}
30+
```
31+
32+
Generalmente tutti si aspettano questo, tuttavia non è compatibile al 100% con il protocollo di iterazione ECMAScript 6. Certe string, ad esempio un emoji (😜), hanno un `.length` di 2 (o anche di più!), ma dovrebbero iterare come 1 unità in un `for-of` loop. Guarda [questo blog post di Jonathan New](https://blog.jonnew.com/posts/poo-dot-length-equals-two) per una spiegazione più dettagliata.
33+
34+
Quando `downlevelIteration` è attivo, TypeScript utilizzerà una funzione ausiliaria che andrà a controllare la presenza di un `Symbol.iterator` (che può essere di tipo nativo o polyfill). Nel caso in cui questa implementazione non ci sia, ritornerai ad un'iterazione index-based.
35+
36+
```ts twoslash
37+
// @target: ES5
38+
// @downlevelIteration
39+
// @showEmit
40+
const str = "Ciao!";
41+
for (const s of str) {
42+
console.log(s);
43+
}
44+
```
45+
46+
Puoi utilizzare [tslib](https://www.npmjs.com/package/tslib) via [importHelpers](#importHelpers) in modo da ridurre il numero di righe inline Javascript:
47+
48+
```ts twoslash
49+
// @target: ES5
50+
// @downlevelIteration
51+
// @importHelpers
52+
// @showEmit
53+
const str = "Ciao!";
54+
for (const s of str) {
55+
console.log(s);
56+
}
57+
```
58+
59+
> > **Nota:** attivare `downlevelIteration` non andrà a migliorare le prestazioni di compliazione se `Symbol.iterator` non è presente in runtime.
60+
61+
#### Esempio: Effetti sullo spray di Array
62+
63+
Questo è un spread di array:
64+
65+
```js
66+
// Crea un nuovo array composto dall'elemento 1 seguito dagli elementi di arr2
67+
const arr = [1, ...arr2];
68+
```
69+
70+
Secondo la descrizione, sembra facile convertirlo in ES5:
71+
72+
```js
73+
// Stessa cosa, no?
74+
const arr = [1].concat(arr2);
75+
```
76+
77+
Tuttavia, questo è visibilmente diverso in certi rari casi. Ad esempio, nel caso un array abbia un "buco", l'index mancante andrà a creare una proprietà *own* nel caso si decida di applicare uno spread, ma non se creato utilizzando `.concat`:
78+
79+
```js
80+
// Crea un array dove manca l'elemento '1'
81+
let mancante = [0, , 1];
82+
let spread = [...mancante];
83+
let concatenato = [].concat(mancante);
84+
85+
// true
86+
"1" in spread;
87+
// false
88+
"1" in concatenato;
89+
```
90+
91+
Proprio come un `for / of`, `downlevelIteration` andrà ad usare `Symbol.iterator` (se presente) in modo da emulare in modo più preciso il comportamento di ES 6.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
display: "Importazione di Aiuti"
3+
oneline: "Permette di importare alcune funzioni ausiliari per il progetto"
4+
5+
---
6+
7+
TypeScript da alcuni suggerimenti per operazioni di livello inferiore come ad esempio estendere classi, spread di array o oggetti, e operazioni asincrone. In modo predefinito, questi suggerimenti vengono dati nei file che usano le operazioni elencate in precedenza. Tuttavia, nel caso in cui lo stesso suggerimento è usato in più moduli diversi, si possono verificare alcuni casi di duplicazione del codice.
8+
9+
Se l'opzione `importHelpers` è attiva, queste funzionalità ausiliari vengono importate dal modulo [tslib](https://www.npmjs.com/package/tslib). Dovrai assicurarti che il modulo `tslib` è in grado di essere importato in runtime. Questo riguarda solo i moduli; I file degli script globali non proveranno ad importare i moduli.
10+
11+
Per esempio, con questo codice TypeScript:
12+
13+
14+
```ts
15+
export function fn(arr: number[]) {
16+
const arr2 = [1, ...arr];
17+
}
18+
```
19+
20+
Attivando [`downlevelIteration`](#downlevelIteration), esso rimane falso:
21+
22+
```ts twoslash
23+
// @showEmit
24+
// @target: ES5
25+
// @downleveliteration
26+
export function fn(arr: number[]) {
27+
const arr2 = [1, ...arr];
28+
}
29+
```
30+
31+
Poi attivando entrambi [`downlevelIteration`](#downlevelIteration) e `importHelpers`:
32+
33+
```ts twoslash
34+
// @showEmit
35+
// @target: ES5
36+
// @downleveliteration
37+
// @importhelpers
38+
// @noErrors
39+
export function fn(arr: number[]) {
40+
const arr2 = [1, ...arr];
41+
}
42+
```
43+
44+
Puoi utilizzare [`noEmitHelpers`](#noEmitHelpers) quando metti a disposizione la tua implementazione di queste funzioni.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
display: "Incrementale"
3+
oneline: "Crea dei file .tsbuildinfo per permettere la compilazione incrementale del progetto"
4+
---
5+
6+
Dice a TypeScript di salvare le informazioni riguardo il grafo del progetto dall'ultima compliazione nei file salvati nel disco.
7+
Questo crea una serie di file `.tsbuildinfo` nella stessa cartella del risultato della compilazione. Essi non vengono usati dal tuo JavaScript durante l'esecuzione e possono essere tranquillamente eliminati. Puoi saperne di più riguardo questa flag nelle [3.4 note di rilascio](/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag).
8+
9+
Per scegliere in che cartella vuoi i tuoi file compilati, usa l'opzione di configurazione [`tsBuildInfoFile`](#tsBuildInfoFile).
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
display: "Moduli Isolati"
3+
oneline: "Si assicura che ogni file possa essere compilato in sicurezza senza basarsi sulle altre importazioni"
4+
---
5+
6+
Quando usi TypeScript per produrre codice JavaScript, è usanza comune usare altri transpilers come ad esempio [Babel](https://babeljs.io).
7+
Tuttavia, gli altri transpilers possono operare solo su un singolo file alla volta, questo significa che non possono fare cambiamenti che dipendono dalla comprensione dell'intero progetto.
8+
Questa regola si applica anche al `ts.transpileModule` API di TypeScript che è usata da alcuni strumenti di esecuzione.
9+
10+
Queste limitazioni possono causare problemi di esecuzione con alcune funzionalità di TypeScript come `const enum` e `namespace`.
11+
Impostando la flag `isolatedModules` chiedi a TypeScript di avvisarti se stai scrivendo del codice che non può essere correttamente interpretato da un processo di transpilation su un singolo file.
12+
13+
Esso non cambia la forma del tuo codice e nemmeno la forma del controllo di TypeScript e il processo di emissione.
14+
15+
Alcuni esempi di codice che non funzionano quando `isolatedModules` è abilitato.
16+
17+
#### Esportazione di idententificatori senza valore
18+
19+
In TypeScript, puoi importare un _type_ e di conseguenza esportarlo:
20+
21+
```ts twoslash
22+
// @noErrors
23+
import { tipo, funzione } from "modulo";
24+
25+
funzione();
26+
27+
export { tipo, funzione };
28+
```
29+
30+
Dato che non ci sono valori per `tipo`, l'emissione `export` non proverà ad esportarlo (questo perché ci sarebbe un errore di esecuzione in JavaScript):
31+
32+
```js
33+
export { funzione };
34+
```
35+
36+
I transpilers a singolo file non sanno se `tipo` produce un valore o meno, quindi c'è un errore nell'esportazione di un nome che si riferisce solo ad un tipo.
37+
38+
#### File Non-Moduli
39+
40+
Se `isolatedModules` è impostato, tutti file di implementazione devono essere _modules_ (ciò significa che esso ha alcune forme di `import` / `export`). Un errore appare se nessun file è un modulo:
41+
42+
```ts twoslash
43+
// @errors: 1208
44+
// @isolatedModules
45+
function fn() {}
46+
```
47+
48+
Questa regola non viene applicata ai file `.d.ts`
49+
50+
#### Riferimenti ai membri `const enum`
51+
52+
In TypeScript, quando ti riferisci ad un membro `const enum`, il riferimento viene rimpiazzato dal suo valore attuale nel JavaScript compilato. Cambiando questo TypeScript:
53+
54+
```ts twoslash
55+
declare const enum Numeri {
56+
Zero = 0,
57+
Uno = 1,
58+
}
59+
console.log(Numeri.Zero + Numeri.Uno);
60+
```
61+
62+
Con questo JavaScript:
63+
64+
```ts twoslash
65+
// @showEmit
66+
// @removeComments
67+
declare const enum Numeri {
68+
Zero = 0,
69+
Uno = 1,
70+
}
71+
console.log(Numeri.Zero + Numeri.Uno);
72+
```
73+
74+
Senza la conoscenza del valore di questi membri, gli altri transpilers non possono rimpiazzare il riferimento a `Numeri`, questo comporterebbe un errore di esecuzione se lasciato a se stesso (dal momento in cui non ci sono oggetti di tipo `Numeri` in esecuzione).
75+
A causa di questo, quando `isolatedModules` è impostato, c'è un errore nel riferire un ambiente ad un membro `const enum`.

0 commit comments

Comments
 (0)