Skip to content

Commit 9296a22

Browse files
authored
Merge pull request #5 from microsoft/main
merge
2 parents 8b12c5c + fb8ae94 commit 9296a22

File tree

10 files changed

+480
-0
lines changed

10 files changed

+480
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// { compiler: { noImplicitAny: false }, order: 2 }
2+
3+
// TypeScript 3.7 버전에 있는 '사용법에서 추론한' 코드 수정은
4+
// 더욱 똑똑해졌습니다. 이제부터는 알려진 중요한
5+
// 타입(문자열, 숫자, 배열, 프로미스)의 리스트로 사용되며,
6+
// 이러한 객체의 API와 일치하는 타입의 사용에 따라
7+
// 유추합니다.
8+
9+
// 다음과 같은 예시에서, 함수의 매개변수를 선택하고
10+
// 전구를 클릭하여, "Infer Parameter types..."를
11+
// 선택합니다.
12+
13+
// 숫자 배열을 유추합니다:
14+
15+
function pushNumber(arr) {
16+
arr.push(12);
17+
}
18+
19+
// 프로미스를 유추합니다:
20+
21+
function awaitPromise(promise) {
22+
promise.then((value) => console.log(value));
23+
}
24+
25+
// 함수와 반환 타입을 유추합니다:
26+
27+
function inferAny(app) {
28+
const result = app.use("hi");
29+
return result;
30+
}
31+
32+
// 문자열이 추가 되었음으로,
33+
// 문자열 배열로 유추합니다:
34+
35+
function insertString(names) {
36+
names[1] = "hello";
37+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//// { compiler: { }, order: 3 }
2+
3+
// TypeScript의 오류 메시지는 가끔 필요 이상으로 상세할 수 있습니다...
4+
// 3.7 버전에서, 몇 가지 터무니없는 사례를 보실 수 있습니다.
5+
6+
// 중첩 속성
7+
8+
let a = { b: { c: { d: { e: "string" } } } };
9+
let b = { b: { c: { d: { e: 12 } } } };
10+
11+
a = b;
12+
13+
// 이전에는, 중첩된 속성 당 두 줄의 코드였기에,
14+
// 오류 메시지의 첫 번째와 마지막 줄을 읽음으로써
15+
// 빠르게 오류 메시지를 읽는 방법을 배웠습니다.
16+
17+
// 이제는 인라인입니다:
18+
19+
// 3.6 버전에서는 다음과 같습니다:
20+
//
21+
// Type '{ b: { c: { d: { e: number; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: string; }; }; }; }'.
22+
// Types of property 'b' are incompatible.
23+
// Type '{ c: { d: { e: number; }; }; }' is not assignable to type '{ c: { d: { e: string; }; }; }'.
24+
// Types of property 'c' are incompatible.
25+
// Type '{ d: { e: number; }; }' is not assignable to type '{ d: { e: string; }; }'.
26+
// Types of property 'd' are incompatible.
27+
// Type '{ e: number; }' is not assignable to type '{ e: string; }'.
28+
// Types of property 'e' are incompatible.
29+
// Type 'number' is not assignable to type 'string'
30+
31+
// 유용하고 간결한 오류 메시지를 제공하여,
32+
// 객체의 여러 타입을 통해 작업을 처리할 수 있습니다.
33+
34+
class ExampleClass {
35+
state = "ok";
36+
}
37+
38+
class OtherClass {
39+
state = 12;
40+
}
41+
42+
let x = { a: { b: { c: { d: { e: { f: ExampleClass } } } } } };
43+
let y = { a: { b: { c: { d: { e: { f: OtherClass } } } } } };
44+
x = y;
45+
46+
// 3.6 버전에서는 다음과 같습니다:
47+
//
48+
// Type '{ a: { b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }; }'.
49+
// Types of property 'a' are incompatible.
50+
// Type '{ b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }'.
51+
// Types of property 'b' are incompatible.
52+
// Type '{ c: { d: { e: { f: typeof OtherClass; }; }; }; }' is not assignable to type '{ c: { d: { e: { f: typeof ExampleClass; }; }; }; }'.
53+
// Types of property 'c' are incompatible.
54+
// Type '{ d: { e: { f: typeof OtherClass; }; }; }' is not assignable to type '{ d: { e: { f: typeof ExampleClass; }; }; }'.
55+
// Types of property 'd' are incompatible.
56+
// Type '{ e: { f: typeof OtherClass; }; }' is not assignable to type '{ e: { f: typeof ExampleClass; }; }'.
57+
// Types of property 'e' are incompatible.
58+
// Type '{ f: typeof OtherClass; }' is not assignable to type '{ f: typeof ExampleClass; }'.
59+
// Types of property 'f' are incompatible.
60+
// Type 'typeof OtherClass' is not assignable to type 'typeof ExampleClass'.
61+
// Type 'OtherClass' is not assignable to type 'ExampleClass'.
62+
// Types of property 'state' are incompatible.
63+
// Type 'number' is not assignable to type 'string'
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//// { order: 2, compiler: { esModuleInterop: true } }
2+
3+
// 함수 체이닝 API는 JavaScript에서 흔한 패턴으로,
4+
// JavaScript 의 중첩 특성으로 인해
5+
// 중간값을 줄이고 가독성을 높혀
6+
// 코드를 집중시킬 수 있습니다.
7+
8+
// 체이닝으로 동작하는 흔한 API는 jQuery입니다.
9+
// DefinitelyTyped의 타입과 함께 사용한
10+
// jQuery 예시입니다.:
11+
12+
import $ from "jquery";
13+
14+
// jQuery API 사용 예시:
15+
16+
$("#navigation").css("background", "red").height(300).fadeIn(200);
17+
18+
// 위 라인에 점을 추가해보면,
19+
// 긴 함수 리스트를 보게 될 것입니다.
20+
// 이 패턴은 JavaScript에서 쉽게 재현할 수 있습니다.
21+
// 핵심은 반드시 항상 같은 오브젝트를 반환하는 것입니다.
22+
23+
// 여기 체이닝 API를 만드는 API 예시가 있습니다.
24+
// 핵심은 내부 상태를 파악하고 있는 외부 함수와
25+
// 항상 자신을 반환하는 API를
26+
// 노출하는 오브젝트를 갖는 것입니다.
27+
28+
const addTwoNumbers = (start = 1) => {
29+
let n = start;
30+
31+
const api = {
32+
// API에 있는 각 함수를 실행하세요
33+
add(inc: number = 1) {
34+
n += inc;
35+
return api;
36+
},
37+
38+
print() {
39+
console.log(n);
40+
return api;
41+
},
42+
};
43+
return api;
44+
};
45+
46+
// jQuery에서 본 것처럼
47+
// 같은 스타일의 API를 허용:
48+
49+
addTwoNumbers(1).add(3).add().print().add(1);
50+
51+
// 클래스를 사용하는 비슷한 예시:
52+
53+
class AddNumbers {
54+
private n: number;
55+
56+
constructor(start = 0) {
57+
this.n = start;
58+
}
59+
60+
public add(inc = 1) {
61+
this.n = this.n + inc;
62+
return this;
63+
}
64+
65+
public print() {
66+
console.log(this.n);
67+
return this;
68+
}
69+
}
70+
71+
// 여기에서 동작:
72+
73+
new AddNumbers(2).add(3).add().print().add(1);
74+
75+
// 이 예시는 JavaScript 패턴에
76+
// 도구를 제공하는 방법을 제공하기 위해서
77+
// TypeScript 타입 추론을 사용했습니다.
78+
79+
// 더 많은 예시:
80+
//
81+
// - example:code-flow

docs/tsconfig/it/options/lib.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
display: "Libreria"
3+
oneline: "Include le definizioni di disponibili nel runtime di JavaScript"
4+
---
5+
6+
TypeScript include una serie di definizioni tipo per API già incorporate in JS (come `Math`), o definizioni tipo per ambienti di sviluppo web (come `document`).
7+
TypeScript include anche API per le nuove funzionalità JS abbinandole al `target` specificato; per esempio il termine `Map` è disponibile se il `target` è `ES6` o una versione più recente.
8+
9+
Potresti volerli cambiare per alcuni motivi:
10+
11+
- Il tuo programma non gira su un browser, quindi non vuoi le definizioni di tipo `"dom"`
12+
- La tua piattaforma di esecuzione fornisce alcuni oggetti API di JavaScript (magari attraverso dei polyfill), ma non supporta la completa sintassi di una determinata versione di ECMAScript
13+
- Hai una serie di polyfill o implementazioni native per alcuni, ma non tutti, per una versione ECMAScript di livello superiore
14+
15+
### Librerie di alto livello
16+
17+
| Nomi | Contenuti |
18+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| `ES5` | Definizioni di base per tutte le funzionalità ES3 e ES5 |
20+
| `ES2015` | APIs aggiuntive disponibili in ES2015 (conosciuto anche come ES6) - `array.find`, `Promise`, `Proxy`, `Symbol`, `Map`, `Set`, `Reflect`, etc. |
21+
| `ES6` | Alias per "ES2015" |
22+
| `ES2016` | APIs aggiuntive dispinibili in ES2016 - `array.include`, etc. |
23+
| `ES7` | Alias per "ES2016" |
24+
| `ES2017` | APIs aggiuntive disponibili in ES2017 - `Object.entries`, `Object.values`, `Atomics`, `SharedArrayBuffer`, `date.formatToParts`, array tipizzati, etc. |
25+
| `ES2018` | APIs aggiuntive disponibili in ES2018 - `async` iterables, `promise.finally`, `Intl.PluralRules`, `rexexp.groups`, etc. |
26+
| `ES2019` | APIs aggiuntive disponibili in ES2019 - `array.flat`,` array.flatMap`, `Object.fromEntries`, `string.trimStart`, `string.trimEnd`, etc. |
27+
| `ES2020` | APIs aggiuntive disponibili in ES2020 - `string.matchAll`, etc. |
28+
| `ESNext` | APIs aggiuntive disponibili in ESNext - Questo cambia con l'evoluzione delle specifiche di JavaScript |
29+
| `DOM` | Definizioni [DOM](https://developer.mozilla.org/docs/Glossary/DOM) - `window`, `document`, etc. |
30+
| `WebWorker` | APIs disponibili in contesti [Web Worker](https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Using_web_workers) |
31+
| `ScriptHost` | APIs per il [Windows Script Hosting System](https://wikipedia.org/wiki/Windows_Script_Host) |
32+
33+
### Componenti di librerie individuali
34+
35+
| Nome |
36+
| ------------------------- |
37+
| `DOM.Iterable` |
38+
| `ES2015.Core` |
39+
| `ES2015.Collection` |
40+
| `ES2015.Generator` |
41+
| `ES2015.Iterable` |
42+
| `ES2015.Promise` |
43+
| `ES2015.Proxy` |
44+
| `ES2015.Reflect` |
45+
| `ES2015.Symbol` |
46+
| `ES2015.Symbol.WellKnown` |
47+
| `ES2016.Array.Include` |
48+
| `ES2017.object` |
49+
| `ES2017.Intl` |
50+
| `ES2017.SharedMemory` |
51+
| `ES2017.String` |
52+
| `ES2017.TypedArrays` |
53+
| `ES2018.Intl` |
54+
| `ES2018.Promise` |
55+
| `ES2018.RegExp` |
56+
| `ES2019.Array` |
57+
| `ES2019.Full` |
58+
| `ES2019.Object` |
59+
| `ES2019.String` |
60+
| `ES2019.Symbol` |
61+
| `ES2020.Full` |
62+
| `ES2020.String` |
63+
| `ES2020.Symbol.wellknown` |
64+
| `ESNext.AsyncIterable` |
65+
| `ESNext.Array` |
66+
| `ESNext.Intl` |
67+
| `ESNext.Symbol` |
68+
69+
70+
Questa lista potrebbe non essere aggiornata, puoi vedere la lista completa nel [codice sorgente di TypeScript](https://github.com/microsoft/TypeScript/tree/master/lib).

docs/tsconfig/it/options/outDir.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
display: "Out Dir"
3+
oneline: "Imposta una directory di output per tutti i file generati."
4+
---
5+
6+
Se viene specificato, i file `.js` (così come `.d.ts`, `.js.map`, etc.) verrano emessi in questa directory.
7+
E' preservata la struttura della directory dei file sorgente originali; controlla [rootDir](#rootDir) se
8+
la root elaborata non è quella che quella che intendevi.
9+
10+
Se non specificato, i file `.js` verranno emessi nella stessa directory dei file `.ts` da cui
11+
sono stati generati:
12+
13+
```sh
14+
$ tsc
15+
16+
esempio
17+
├── index.js
18+
└── index.ts
19+
```
20+
21+
Con un `tsconfig.json`così:
22+
23+
```json tsconfig
24+
{
25+
"opzioniCompilatore": {
26+
"outDir": "dist"
27+
}
28+
}
29+
```
30+
31+
Eseguendo `tsc` con queste opzioni si andrà a spostare i file nella cartella `dist` specificata:
32+
33+
```sh
34+
$ tsc
35+
36+
esempio
37+
├── dist
38+
│ └── index.js
39+
├── index.ts
40+
└── tsconfig.json
41+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
display: "Rimuovere commenti"
3+
oneline: "Rimuove commenti di TypeScript in modo da non venire visualizzati in JavaScript"
4+
5+
---
6+
7+
Rimuove tutti i commenti dai file TypeScript quando avviene la conversione in JavaScript. Il valore predefinito è `false`.
8+
9+
Per esempio, questo è un file TypeScript che ha un commento JSDoc:
10+
11+
```ts
12+
/** Traduzione di 'Ciao mondo' in italiano. */
13+
export const ciaoMondoIT = "Ciao mondo";
14+
```
15+
16+
Quando `removeComments` è impostato su `true`:
17+
18+
```ts twoslash
19+
// @showEmit
20+
// @removeComments: true
21+
/** Traduzione di 'Ciao mondo' in italiano. */
22+
export const ciaoMondoIT = "Ciao mondo";
23+
```
24+
25+
Senza aver impostato `removeComments` o averlo impostato su `false`:
26+
27+
```ts twoslash
28+
// @showEmit
29+
// @removeComments: false
30+
/** Traduzione di 'Ciao mondo' in italiano. */
31+
export const ciaoMondoIT = "Ciao mondo";
32+
```
33+
34+
Ciò significa che i tuoi commenti verranno visualizzati nel codice JavaScript.

docs/tsconfig/ko/options/composite.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
display: "Composite"
3+
oneline: "Enable constraints that allow a TypeScript project to be used with project references."
4+
---
5+
6+
`composite` 옵션은 아직 빌드되지 않은 프로젝트의 빠른 빌드 설정을 위해 빌드 도구(`—build` 모드에서 TypeScript를 포함한)에 특정 조건을 적용합니다.
7+
8+
이 설정이 켜져 있으면:
9+
10+
- 만약 `rootDir` 설정이 설정되어 있지 않다면, 기본값은 'tsconfig.json' 파일을 포함하는 디렉터리입니다.
11+
12+
- 모든 실행 파일은 `include` 패턴과 일치하거나 `파일` 배열에 나열되어야 합니다. 만약 이 제약 조건을 위반하면, 'tsc'는 지정되지 않은 파일을 알려줍니다.
13+
14+
- `declaration`의 기본값은 `true` 입니다.
15+
16+
TypeScript 프로젝트에 대한 문서는 [핸드북](https://www.typescriptlang.org/docs/handbook/project-references.html)에서 확인할 수 있습니다.

0 commit comments

Comments
 (0)