Skip to content

Commit

Permalink
Merge pull request #5 from microsoft/main
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
iGieri committed Feb 11, 2021
2 parents 8b12c5c + fb8ae94 commit 9296a22
Show file tree
Hide file tree
Showing 10 changed files with 480 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/playground/ko/3-7/Fixits/Infer From Usage Changes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//// { compiler: { noImplicitAny: false }, order: 2 }

// TypeScript 3.7 버전에 있는 '사용법에서 추론한' 코드 수정은
// 더욱 똑똑해졌습니다. 이제부터는 알려진 중요한
// 타입(문자열, 숫자, 배열, 프로미스)의 리스트로 사용되며,
// 이러한 객체의 API와 일치하는 타입의 사용에 따라
// 유추합니다.

// 다음과 같은 예시에서, 함수의 매개변수를 선택하고
// 전구를 클릭하여, "Infer Parameter types..."를
// 선택합니다.

// 숫자 배열을 유추합니다:

function pushNumber(arr) {
arr.push(12);
}

// 프로미스를 유추합니다:

function awaitPromise(promise) {
promise.then((value) => console.log(value));
}

// 함수와 반환 타입을 유추합니다:

function inferAny(app) {
const result = app.use("hi");
return result;
}

// 문자열이 추가 되었음으로,
// 문자열 배열로 유추합니다:

function insertString(names) {
names[1] = "hello";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//// { compiler: { }, order: 3 }

// TypeScript의 오류 메시지는 가끔 필요 이상으로 상세할 수 있습니다...
// 3.7 버전에서, 몇 가지 터무니없는 사례를 보실 수 있습니다.

// 중첩 속성

let a = { b: { c: { d: { e: "string" } } } };
let b = { b: { c: { d: { e: 12 } } } };

a = b;

// 이전에는, 중첩된 속성 당 두 줄의 코드였기에,
// 오류 메시지의 첫 번째와 마지막 줄을 읽음으로써
// 빠르게 오류 메시지를 읽는 방법을 배웠습니다.

// 이제는 인라인입니다:

// 3.6 버전에서는 다음과 같습니다:
//
// Type '{ b: { c: { d: { e: number; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: string; }; }; }; }'.
// Types of property 'b' are incompatible.
// Type '{ c: { d: { e: number; }; }; }' is not assignable to type '{ c: { d: { e: string; }; }; }'.
// Types of property 'c' are incompatible.
// Type '{ d: { e: number; }; }' is not assignable to type '{ d: { e: string; }; }'.
// Types of property 'd' are incompatible.
// Type '{ e: number; }' is not assignable to type '{ e: string; }'.
// Types of property 'e' are incompatible.
// Type 'number' is not assignable to type 'string'

// 유용하고 간결한 오류 메시지를 제공하여,
// 객체의 여러 타입을 통해 작업을 처리할 수 있습니다.

class ExampleClass {
state = "ok";
}

class OtherClass {
state = 12;
}

let x = { a: { b: { c: { d: { e: { f: ExampleClass } } } } } };
let y = { a: { b: { c: { d: { e: { f: OtherClass } } } } } };
x = y;

// 3.6 버전에서는 다음과 같습니다:
//
// Type '{ a: { b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }; }'.
// Types of property 'a' are incompatible.
// Type '{ b: { c: { d: { e: { f: typeof OtherClass; }; }; }; }; }' is not assignable to type '{ b: { c: { d: { e: { f: typeof ExampleClass; }; }; }; }; }'.
// Types of property 'b' are incompatible.
// Type '{ c: { d: { e: { f: typeof OtherClass; }; }; }; }' is not assignable to type '{ c: { d: { e: { f: typeof ExampleClass; }; }; }; }'.
// Types of property 'c' are incompatible.
// Type '{ d: { e: { f: typeof OtherClass; }; }; }' is not assignable to type '{ d: { e: { f: typeof ExampleClass; }; }; }'.
// Types of property 'd' are incompatible.
// Type '{ e: { f: typeof OtherClass; }; }' is not assignable to type '{ e: { f: typeof ExampleClass; }; }'.
// Types of property 'e' are incompatible.
// Type '{ f: typeof OtherClass; }' is not assignable to type '{ f: typeof ExampleClass; }'.
// Types of property 'f' are incompatible.
// Type 'typeof OtherClass' is not assignable to type 'typeof ExampleClass'.
// Type 'OtherClass' is not assignable to type 'ExampleClass'.
// Types of property 'state' are incompatible.
// Type 'number' is not assignable to type 'string'
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//// { order: 2, compiler: { esModuleInterop: true } }

// 함수 체이닝 API는 JavaScript에서 흔한 패턴으로,
// JavaScript 의 중첩 특성으로 인해
// 중간값을 줄이고 가독성을 높혀
// 코드를 집중시킬 수 있습니다.

// 체이닝으로 동작하는 흔한 API는 jQuery입니다.
// DefinitelyTyped의 타입과 함께 사용한
// jQuery 예시입니다.:

import $ from "jquery";

// jQuery API 사용 예시:

$("#navigation").css("background", "red").height(300).fadeIn(200);

// 위 라인에 점을 추가해보면,
// 긴 함수 리스트를 보게 될 것입니다.
// 이 패턴은 JavaScript에서 쉽게 재현할 수 있습니다.
// 핵심은 반드시 항상 같은 오브젝트를 반환하는 것입니다.

// 여기 체이닝 API를 만드는 API 예시가 있습니다.
// 핵심은 내부 상태를 파악하고 있는 외부 함수와
// 항상 자신을 반환하는 API를
// 노출하는 오브젝트를 갖는 것입니다.

const addTwoNumbers = (start = 1) => {
let n = start;

const api = {
// API에 있는 각 함수를 실행하세요
add(inc: number = 1) {
n += inc;
return api;
},

print() {
console.log(n);
return api;
},
};
return api;
};

// jQuery에서 본 것처럼
// 같은 스타일의 API를 허용:

addTwoNumbers(1).add(3).add().print().add(1);

// 클래스를 사용하는 비슷한 예시:

class AddNumbers {
private n: number;

constructor(start = 0) {
this.n = start;
}

public add(inc = 1) {
this.n = this.n + inc;
return this;
}

public print() {
console.log(this.n);
return this;
}
}

// 여기에서 동작:

new AddNumbers(2).add(3).add().print().add(1);

// 이 예시는 JavaScript 패턴에
// 도구를 제공하는 방법을 제공하기 위해서
// TypeScript 타입 추론을 사용했습니다.

// 더 많은 예시:
//
// - example:code-flow
70 changes: 70 additions & 0 deletions docs/tsconfig/it/options/lib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
display: "Libreria"
oneline: "Include le definizioni di disponibili nel runtime di JavaScript"
---

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`).
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.

Potresti volerli cambiare per alcuni motivi:

- Il tuo programma non gira su un browser, quindi non vuoi le definizioni di tipo `"dom"`
- 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
- Hai una serie di polyfill o implementazioni native per alcuni, ma non tutti, per una versione ECMAScript di livello superiore

### Librerie di alto livello

| Nomi | Contenuti |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ES5` | Definizioni di base per tutte le funzionalità ES3 e ES5 |
| `ES2015` | APIs aggiuntive disponibili in ES2015 (conosciuto anche come ES6) - `array.find`, `Promise`, `Proxy`, `Symbol`, `Map`, `Set`, `Reflect`, etc. |
| `ES6` | Alias per "ES2015" |
| `ES2016` | APIs aggiuntive dispinibili in ES2016 - `array.include`, etc. |
| `ES7` | Alias per "ES2016" |
| `ES2017` | APIs aggiuntive disponibili in ES2017 - `Object.entries`, `Object.values`, `Atomics`, `SharedArrayBuffer`, `date.formatToParts`, array tipizzati, etc. |
| `ES2018` | APIs aggiuntive disponibili in ES2018 - `async` iterables, `promise.finally`, `Intl.PluralRules`, `rexexp.groups`, etc. |
| `ES2019` | APIs aggiuntive disponibili in ES2019 - `array.flat`,` array.flatMap`, `Object.fromEntries`, `string.trimStart`, `string.trimEnd`, etc. |
| `ES2020` | APIs aggiuntive disponibili in ES2020 - `string.matchAll`, etc. |
| `ESNext` | APIs aggiuntive disponibili in ESNext - Questo cambia con l'evoluzione delle specifiche di JavaScript |
| `DOM` | Definizioni [DOM](https://developer.mozilla.org/docs/Glossary/DOM) - `window`, `document`, etc. |
| `WebWorker` | APIs disponibili in contesti [Web Worker](https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Using_web_workers) |
| `ScriptHost` | APIs per il [Windows Script Hosting System](https://wikipedia.org/wiki/Windows_Script_Host) |

### Componenti di librerie individuali

| Nome |
| ------------------------- |
| `DOM.Iterable` |
| `ES2015.Core` |
| `ES2015.Collection` |
| `ES2015.Generator` |
| `ES2015.Iterable` |
| `ES2015.Promise` |
| `ES2015.Proxy` |
| `ES2015.Reflect` |
| `ES2015.Symbol` |
| `ES2015.Symbol.WellKnown` |
| `ES2016.Array.Include` |
| `ES2017.object` |
| `ES2017.Intl` |
| `ES2017.SharedMemory` |
| `ES2017.String` |
| `ES2017.TypedArrays` |
| `ES2018.Intl` |
| `ES2018.Promise` |
| `ES2018.RegExp` |
| `ES2019.Array` |
| `ES2019.Full` |
| `ES2019.Object` |
| `ES2019.String` |
| `ES2019.Symbol` |
| `ES2020.Full` |
| `ES2020.String` |
| `ES2020.Symbol.wellknown` |
| `ESNext.AsyncIterable` |
| `ESNext.Array` |
| `ESNext.Intl` |
| `ESNext.Symbol` |


Questa lista potrebbe non essere aggiornata, puoi vedere la lista completa nel [codice sorgente di TypeScript](https://github.com/microsoft/TypeScript/tree/master/lib).
41 changes: 41 additions & 0 deletions docs/tsconfig/it/options/outDir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
display: "Out Dir"
oneline: "Imposta una directory di output per tutti i file generati."
---

Se viene specificato, i file `.js` (così come `.d.ts`, `.js.map`, etc.) verrano emessi in questa directory.
E' preservata la struttura della directory dei file sorgente originali; controlla [rootDir](#rootDir) se
la root elaborata non è quella che quella che intendevi.

Se non specificato, i file `.js` verranno emessi nella stessa directory dei file `.ts` da cui
sono stati generati:

```sh
$ tsc

esempio
├── index.js
└── index.ts
```

Con un `tsconfig.json`così:

```json tsconfig
{
"opzioniCompilatore": {
"outDir": "dist"
}
}
```

Eseguendo `tsc` con queste opzioni si andrà a spostare i file nella cartella `dist` specificata:

```sh
$ tsc

esempio
├── dist
│ └── index.js
├── index.ts
└── tsconfig.json
```
34 changes: 34 additions & 0 deletions docs/tsconfig/it/options/removeComments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
display: "Rimuovere commenti"
oneline: "Rimuove commenti di TypeScript in modo da non venire visualizzati in JavaScript"

---

Rimuove tutti i commenti dai file TypeScript quando avviene la conversione in JavaScript. Il valore predefinito è `false`.

Per esempio, questo è un file TypeScript che ha un commento JSDoc:

```ts
/** Traduzione di 'Ciao mondo' in italiano. */
export const ciaoMondoIT = "Ciao mondo";
```

Quando `removeComments` è impostato su `true`:

```ts twoslash
// @showEmit
// @removeComments: true
/** Traduzione di 'Ciao mondo' in italiano. */
export const ciaoMondoIT = "Ciao mondo";
```

Senza aver impostato `removeComments` o averlo impostato su `false`:

```ts twoslash
// @showEmit
// @removeComments: false
/** Traduzione di 'Ciao mondo' in italiano. */
export const ciaoMondoIT = "Ciao mondo";
```

Ciò significa che i tuoi commenti verranno visualizzati nel codice JavaScript.
16 changes: 16 additions & 0 deletions docs/tsconfig/ko/options/composite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
display: "Composite"
oneline: "Enable constraints that allow a TypeScript project to be used with project references."
---

`composite` 옵션은 아직 빌드되지 않은 프로젝트의 빠른 빌드 설정을 위해 빌드 도구(`—build` 모드에서 TypeScript를 포함한)에 특정 조건을 적용합니다.

이 설정이 켜져 있으면:

- 만약 `rootDir` 설정이 설정되어 있지 않다면, 기본값은 'tsconfig.json' 파일을 포함하는 디렉터리입니다.

- 모든 실행 파일은 `include` 패턴과 일치하거나 `파일` 배열에 나열되어야 합니다. 만약 이 제약 조건을 위반하면, 'tsc'는 지정되지 않은 파일을 알려줍니다.

- `declaration`의 기본값은 `true` 입니다.

TypeScript 프로젝트에 대한 문서는 [핸드북](https://www.typescriptlang.org/docs/handbook/project-references.html)에서 확인할 수 있습니다.
Loading

0 comments on commit 9296a22

Please sign in to comment.