Skip to content

Commit 5785c8d

Browse files
Merge pull request #22 from paigekim29/main
translation 4 files to Ko
2 parents a77cbc6 + 0053c6e commit 5785c8d

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed
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+
}
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'
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`를 추가해야만, 모듈로 간주됩니다.
+3
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)