Skip to content

Commit 6b5eeff

Browse files
authored
Merge pull request #5 from microsoft/main
Update
2 parents a5a1eba + fb8ae94 commit 6b5eeff

File tree

10 files changed

+373
-0
lines changed

10 files changed

+373
-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/noEmit.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
display: "Non genera"
3+
oneline: "Non genera file da una compilazione"
4+
---
5+
6+
Il compilatore non genera file di output come ad esempio codice JavaScript, source maps o dichiarazioni.
7+
8+
Questo fa spazio per altri strumenti come [Babel](https://babeljs.io) o [swc](https://github.com/swc-project/swc) per gestire la conversione di un file TypeScript in un file che può essere eseguito in un ambiente JavaScript
9+
10+
Puoi usare TypeScript come uno strumento che ti offre un integrazione da parte dell'editor e un codice sorgente tipizzato.

docs/tsconfig/it/options/outFile.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
display: "File di output"
3+
oneline: "Crea un solo file js che contiene tutti i file concatenati"
4+
---
5+
6+
Se specificato, tutti i file _global_ (non moduli) verranno concatenati in un unico file output specificato.
7+
8+
Se `module` è `system` o `amd`, tutti i file _module_ saranno concatenati in questo file dopo tutto il contenuto globale.
9+
10+
Nota: `outFile` non può essere a meno che `module` è `None`, `System`, o `AMD`.
11+
Questa opzione _non può_ essere usata insieme a CommonJS o moduli ES6.

docs/tsconfig/it/options/plugins.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
display: "Plugins"
3+
oneline: "La lista dei plugin inclusi nel codice"
4+
---
5+
6+
Lista dei language service plugin da eseguire all'interno dell'editor.
7+
8+
I language service plugin sono un modo di dare più informazioni all'utente riguardo i file TypeScript esistenti. Loro possono sfruttare i messaggi di TypeScript e dell'editor per creare i loro errori.
9+
10+
Per esempio:
11+
12+
- [ts-sql-plugin](https://github.com/xialvjun/ts-sql-plugin#readme) — Aggiunge Linting SQL con un generatore di stringhe SQL.
13+
- [typescript-styled-plugin](https://github.com/Microsoft/typescript-styled-plugin) — Aggiunge Linting CSS all'interno delle stringhe di template.
14+
- [typescript-eslint-language-service](https://github.com/Quramy/typescript-eslint-language-service) — Da un errore di eslint e il corrispettivo fix all'interno dell'output del compilatore.
15+
- [ts-graphql-plugin](https://github.com/Quramy/ts-graphql-plugin) — Da validazione e autocompletamento all'interno delle stringhe con query GraphQL.
16+
17+
VS Code ha l'abilità grazie alle estensioni di [includere automaticamente i language service plugin](https://code.visualstudio.com/api/references/contribution-points#contributes.typescriptServerPlugins), quindi è probabile che ne stai già eseguendo alcuni nel tuo editor senza aver bisogno di definirli nel `tsconfig.json`.

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)에서 확인할 수 있습니다.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
display: "jsxImportSource"
3+
oneline: "Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`"
4+
---
5+
6+
Typescript 4.1 버전에 소개된 [jsx](#jsx)`"react-jsx"` 또는 `"react-jsxdev"`로 사용할 때, `jsx``jsxs` 팩터리 함수를 import 하는데 사용할 모듈 지정자를 선언합니다.
7+
8+
[React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)에서, 라이브러리는 독립된 import를 통하여 새로운 형태의 JSX 변환을 지원해 줍니다.
9+
10+
예를 들어:
11+
12+
```tsx
13+
import React from "react";
14+
15+
function App() {
16+
return <h1>Hello World</h1>;
17+
}
18+
```
19+
20+
TSConfig 사용할 때:
21+
22+
```json tsconfig
23+
{
24+
"compilerOptions": {
25+
"target": "esnext",
26+
"module": "commonjs",
27+
"jsx": "react-jsx"
28+
}
29+
}
30+
```
31+
32+
TypeScript에서 컴파일 된 JavaScript는:
33+
34+
```tsx twoslash
35+
// @showEmit
36+
// @noErrors
37+
// @jsx: react-jsx
38+
// @module: commonjs
39+
// @target: esnext
40+
declare module JSX {
41+
interface Element {}
42+
interface IntrinsicElements {
43+
[s: string]: any;
44+
}
45+
}
46+
import React from "react";
47+
48+
function App() {
49+
return <h1>Hello World</h1>;
50+
}
51+
```
52+
53+
예를 들어, `"jsxImportSource": "preact"`를 사용하고 싶으시면, 다음과 같은 tsconfig를 이용하시면 됩니다:
54+
55+
```json tsconfig
56+
{
57+
"compilerOptions": {
58+
"target": "esnext",
59+
"module": "commonjs",
60+
"jsx": "react-jsx",
61+
"jsxImportSource": "preact",
62+
"types": ["preact"]
63+
}
64+
}
65+
```
66+
67+
다음과 같은 코드를 생성합니다:
68+
69+
```tsx twoslash
70+
// @showEmit
71+
// @jsxImportSource: preact
72+
// @types: preact
73+
// @jsx: react-jsx
74+
// @target: esnext
75+
// @module: commonjs
76+
// @noErrors
77+
78+
export function App() {
79+
return <h1>Hello World</h1>;
80+
}
81+
```
82+
83+
또는, 파일 별 프래그마(per-file pragma)를 이용하여 다음과 같은 옵션을 설정할 수 있습니다:
84+
85+
```tsx
86+
/** @jsxImportSource preact */
87+
88+
export function App() {
89+
return <h1>Hello World</h1>;
90+
}
91+
```
92+
93+
`_jsx`팩토리를 위한 import로서 `preact/jsx-runtime`를 추가합니다.
94+
95+
_노트:_ 의도한 대로 작동이 되려면, `tsx`파일은 `export` 또는 `import`를 추가해야만, 모듈로 간주됩니다.

docs/tsconfig/ko/options/listFiles.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
display: "List Files"
3+
oneline: "Print all of the files read during the compilation."
4+
---
5+
6+
컴파일하는 파일 이름을 출력합니다.
7+
이 기능은 TypeScript에 예상한 파일이 포함되어 있는지 확실하지 않을 때 유용합니다.
8+
9+
예를들면:
10+
11+
```
12+
example
13+
├── index.ts
14+
├── package.json
15+
└── tsconfig.json
16+
```
17+
18+
다음과 같습니다:
19+
20+
```json tsconfig
21+
{
22+
"compilerOptions": {
23+
"listFiles": true
24+
}
25+
}
26+
```
27+
28+
echo paths는 다음과 같습니다:
29+
30+
```
31+
$ npm run tsc
32+
path/to/example/node_modules/typescript/lib/lib.d.ts
33+
path/to/example/node_modules/typescript/lib/lib.es5.d.ts
34+
path/to/example/node_modules/typescript/lib/lib.dom.d.ts
35+
path/to/example/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
36+
path/to/example/node_modules/typescript/lib/lib.scripthost.d.ts
37+
path/to/example/index.ts
38+
```
39+
40+
TypeScript 4.2 버전을 사용할 경우 [`explainFiles`](#explainFiles)을 참조하십시오. 파일이 추가된 이유에 대한 설명 또한 제공합니다.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 루트 필드(Root Fields)
2+
3+
TSConfig의 시작은 루트 옵션입니다 - 이 옵션은 TypeScript 또는 JavaScript 프로젝트 설정과 관련이 있습니다.

0 commit comments

Comments
 (0)