Skip to content

Commit e0a8d3c

Browse files
ssMinjiseohyun0120allcontributors[bot]yeonjuan
authored
translate TS for JS Programmers(Defining Types) (#141)
* translate TS for JS Programmers(Defining Types) * Literal types issue115 (#139) * 1μ°¨ λ²ˆμ—­ * 원문 μ‚­μ œ, 더 λ§€λ„λŸ½κ²Œ λ²ˆμ—­ * λ§žμΆ€λ²• μˆ˜μ • * Babel with typescript issue118 (#138) * μ˜μ–΄ 1μ°¨ λ²ˆμ—­ * 원문 μ‚­μ œ, 더 λ§€λ„λŸ¬μš΄ λ²ˆμ—­μ²΄λ‘œ μˆ˜μ • * λ§€λ„λŸ¬μš΄ λ²ˆμ—­μ²΄λ‘œ μΆ”κ°€ μˆ˜μ • * 1μ°¨ μˆ˜μ • * 2μ°¨ μˆ˜μ • * 3μ°¨ μˆ˜μ • * docs: add seohyun0120 as a contributor (#140) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> * 1μ°¨ λ²ˆμ—­ * 원문 μ‚­μ œ, 더 λ§€λ„λŸ½κ²Œ λ²ˆμ—­ * λ§žμΆ€λ²• μˆ˜μ • * ts twoslashκ°€ μ œλŒ€λ‘œ μž‘λ™ν•˜μ§€ μ•ŠλŠ” 문제 μˆ˜μ • (twoslash μ‚­μ œ) * 2μ°¨ μˆ˜μ • * contributors 정보 μˆ˜μ • Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> * specify node version to 12.18.2 * npm audit * translate TS for JS Programmers(Defining Types) * 리뷰에 따라 λ‚΄μš© μˆ˜μ • * fix push conflict Co-authored-by: Seohyun Yoon <[email protected]> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: YeonJuan <[email protected]>
1 parent 2e3b7d1 commit e0a8d3c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

β€Žpages/tutorials/ts-for-js-programmers.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ permalink: /docs/handbook/typescript-in-5-minutes.html
55
oneline: Learn how TypeScript extends JavaScript
66
---
77

8-
The relationship between TypeScript and JavaScript is rather unique among modern programming languages.
9-
TypeScript sits as a layer on-top of JavaScript, offering the features of JavaScript and then adds its own layer on top of that. This layer is the TypeScript type system.
8+
ν˜„λŒ€ ν”„λ‘œκ·Έλž˜λ° μ–Έμ–΄μ—μ„œ TypeScript와 JavaScript의 κ΄€κ³„λŠ” λ‹€μ†Œ λ…νŠΉν•©λ‹ˆλ‹€.
9+
TypeScript은 JavaScript μœ„μ— λ ˆμ΄μ–΄λ‘œμ„œ 자리작고 μžˆλŠ”λ°, JavaScript의 κΈ°λŠ₯듀을 μ œκ³΅ν•˜λ©΄μ„œ κ·Έ μœ„μ— 자체 λ ˆμ΄μ–΄λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€. 이 λ ˆμ΄μ–΄κ°€ TypeScript νƒ€μž… μ‹œμŠ€ν…œμž…λ‹ˆλ‹€.
1010

11-
JavaScript already has a set of language primitives like `string`, `number`, `object`, `undefined` etc, however there are no ahead-of-time checks that these are consistently assigned across your whole codebase. TypeScript acts as that layer.
11+
JavaScriptλŠ” 이미 `string`, `number`, `object`, `undefined` 같은 μ›μ‹œ νƒ€μž…μ„ κ°€μ§€κ³  μžˆμ§€λ§Œ, 전체 μ½”λ“œλ² μ΄μŠ€μ— μΌκ΄€λ˜κ²Œ ν• λ‹Ήλ˜μ—ˆλŠ”μ§€λŠ” 미리 확인해 μ£Όμ§€ μ•ŠμŠ΅λ‹ˆλ‹€. TypeScriptλŠ” 이 λ ˆμ΄μ–΄λ‘œμ„œ λ™μž‘ν•©λ‹ˆλ‹€.
1212

13-
This means that your existing working JavaScript code is also TypeScript code, however TypeScript's type-checker might highlight discrepancies between what you thought was happening and what the JavaScript language does.
13+
μ΄λŠ” 이미 μ‘΄μž¬ν•˜κ³  잘 λ™μž‘ν•˜λŠ” JavaScript μ½”λ“œλŠ” λ™μ‹œμ— TypeScript μ½”λ“œλΌλŠ” μ˜λ―Έμ§€λ§Œ, TypeScript의 νƒ€μž… κ²€μ‚¬κΈ°λŠ” μ‚¬μš©μžκ°€ μƒκ°ν•œ 일과 JavaScriptκ°€ μ‹€μ œλ‘œ ν•˜λŠ” 일 μ‚¬μ΄μ˜ 뢈일치λ₯Ό κ°•μ‘°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
1414

15-
This tutorial tries to give you a 5 minute overview of the type-system, with a focus on understanding the type-system language extensions which TypeScript adds.
15+
이 νŠœν† λ¦¬μ–Όμ€ TypeScriptκ°€ μΆ”κ°€ν•˜λŠ” νƒ€μž… μ‹œμŠ€ν…œ μ–Έμ–΄ ν™•μž₯을 μ΄ν•΄ν•˜λŠ”λ° 쀑점을 두고 νƒ€μž… μ‹œμŠ€ν…œμ— λŒ€ν•œ 5λΆ„ κ°œμš”λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.
1616

17-
## Types by Inference
17+
## νƒ€μž… μΆ”λ‘  (Types by Inference)
1818

19-
TypeScript knows the JavaScript language and will generate types for you in many cases.
20-
For example in creating a variable and assigning it to a particular value, TypeScript will use the value as its type.
19+
TypeScriptλŠ” JavaScript μ–Έμ–΄λ₯Ό μ•Œκ³  있으며 λŒ€λΆ€λΆ„μ˜ 경우 νƒ€μž…μ„ 생성해쀄 κ²ƒμž…λ‹ˆλ‹€.
20+
예λ₯Ό λ“€μ–΄ λ³€μˆ˜λ₯Ό μƒμ„±ν•˜λ©΄μ„œ λ™μ‹œμ— νŠΉμ • 값에 ν• λ‹Ήν•˜λŠ” 경우, TypeScriptλŠ” κ·Έ 값을 ν•΄λ‹Ή λ³€μˆ˜μ˜ νƒ€μž…μœΌλ‘œ μ‚¬μš©ν•  κ²ƒμž…λ‹ˆλ‹€.
2121

2222
```ts twoslash
2323
let helloWorld = "Hello World";
2424
// ^?
2525
```
2626

27-
By understanding how JavaScript works, TypeScript can build a type-system which accepts JavaScript code but has types. This offers a type-system without needing to add extra characters to make types explicit in your code. Which is how TypeScript knows that `helloWorld` is a `string` in the above example.
27+
JavaScriptκ°€ λ™μž‘ν•˜λŠ” 방식을 μ΄ν•΄ν•¨μœΌλ‘œμ¨ TypeScriptλŠ” JavaScript μ½”λ“œλ₯Ό λ°›μ•„λ“€μ΄λ©΄μ„œ νƒ€μž…μ„ κ°€μ§€λŠ” νƒ€μž… μ‹œμŠ€ν…œμ„ ꡬ좕할 수 μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” μ½”λ“œμ—μ„œ νƒ€μž…μ„ λͺ…μ‹œν•˜κΈ° μœ„ν•΄ μΆ”κ°€λ‘œ 문자λ₯Ό μ‚¬μš©ν•  ν•„μš”κ°€ μ—†λŠ” νƒ€μž… μ‹œμŠ€ν…œμ„ μ œκ³΅ν•©λ‹ˆλ‹€. 이것이 μœ„μ˜ μ˜ˆμ œμ—μ„œ TypeScriptκ°€ `helloWorld`κ°€ `string`μž„μ„ μ•Œκ²Œ λ˜λŠ” λ°©μ‹μž…λ‹ˆλ‹€.
2828

29-
It's quite possible that you have used VS Code with JavaScript, and had editor auto-completion as you worked.
30-
That is because the understanding of JavaScript baked into TypeScript has been used under-the-hood to improve working with JavaScript.
29+
JavaScript와 ν•¨κ»˜ VS Codeλ₯Ό μ‚¬μš©ν•˜κ³  μž‘μ—…μ„ ν•  λ•Œ νŽΈμ§‘κΈ°μ˜ μžλ™ μ™„μ„± κΈ°λŠ₯을 μ‚¬μš©ν•΄μ™”μ„ κ²ƒμž…λ‹ˆλ‹€.
30+
μ΄λŠ” TypeScript에 ν•„μˆ˜λΆˆκ°€κ²°ν•œ JavaScript에 λŒ€ν•œ 이해가 JavaScript μž‘μ—…μ„ κ°œμ„ ν•˜κΈ° μœ„ν•΄ λ‚΄λΆ€μ μœΌλ‘œ μ‚¬μš©λ˜μ—ˆκΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.
3131

32-
## Defining Types
32+
## νƒ€μž… μ •μ˜ν•˜κΈ° (Defining Types)
3333

34-
JavaScript is a dynamic language which allows for a lot of design patterns. Some design patterns can be hard to provide types for automatically (because they might use dynamic programming) in those cases TypeScript supports an extension of the JavaScript language which offers places for you to tell TypeScript what the types should be.
34+
JavaScriptλŠ” λ‹€μ–‘ν•œ λ””μžμΈ νŒ¨ν„΄μ„ κ°€λŠ₯ν•˜κ²Œ ν•˜λŠ” 동적 μ–Έμ–΄μž…λ‹ˆλ‹€. λͺ‡λͺ‡ λ””μžμΈ νŒ¨ν„΄μ€ μžλ™μœΌλ‘œ νƒ€μž…μ„ μ œκ³΅ν•˜κΈ° νž˜λ“€ 수 μžˆλŠ”λ° (동적 ν”„λ‘œκ·Έλž˜λ°μ„ μ‚¬μš©ν•˜κ³  μžˆμ„ 것이기 λ•Œλ¬Έμ—) μ΄λŸ¬ν•œ κ²½μš°μ— TypeScriptλŠ” TypeScriptμ—κ²Œ νƒ€μž…μ΄ 무엇이 λ˜μ–΄μ•Ό ν•˜λŠ”μ§€ λͺ…μ‹œ κ°€λŠ₯ν•œ JavaScript μ–Έμ–΄μ˜ ν™•μž₯을 μ§€μ›ν•©λ‹ˆλ‹€.
3535

36-
Here is an example of creating an object which has an inferred type which includes `name: string` and `id: number`:
36+
λ‹€μŒμ€ `name: string`κ³Ό `id: number`을 ν¬ν•¨ν•˜λŠ” μΆ”λ‘  νƒ€μž…μ„ κ°€μ§„ 객체λ₯Ό μƒμ„±ν•˜λŠ” μ˜ˆμ œμž…λ‹ˆλ‹€.
3737

3838
```ts twoslash
3939
const user = {
@@ -42,7 +42,7 @@ const user = {
4242
};
4343
```
4444

45-
An explicit way to describe this object's shape is via an `interface` declaration:
45+
이 객체의 ν˜•νƒœλ₯Ό λͺ…μ‹œμ μœΌλ‘œ λ‚˜νƒ€λ‚΄κΈ° μœ„ν•΄μ„œλŠ” `interface` 둜 μ„ μ–Έν•©λ‹ˆλ‹€.
4646

4747
```ts twoslash
4848
interface User {
@@ -51,7 +51,7 @@ interface User {
5151
}
5252
```
5353

54-
You can then declare that a JavaScript object conforms to that shape of your new `interface` by using syntax like `: TypeName` after a variable declaration:
54+
이제 λ³€μˆ˜ μ„ μ–Έ 뒀에 `: TypeName`의 ꡬ문을 μ‚¬μš©ν•΄ JavaScript 객체가 μƒˆλ‘œμš΄ `interface`의 ν˜•νƒœλ₯Ό λ”°λ₯΄κ³  μžˆμŒμ„ μ„ μ–Έν•  수 μžˆμŠ΅λ‹ˆλ‹€.
5555

5656
```ts twoslash
5757
interface User {
@@ -65,7 +65,7 @@ const user: User = {
6565
};
6666
```
6767

68-
TypeScript will warn you if you provide an object which doesn't match the interface you have provided:
68+
ν•΄λ‹Ή μΈν„°νŽ˜μ΄μŠ€μ— λ§žμ§€ μ•ŠλŠ” 객체λ₯Ό μƒμ„±ν•˜λ©΄ TypeScriptλŠ” κ²½κ³ λ₯Ό μ€λ‹ˆλ‹€.
6969

7070
```ts twoslash
7171
// @errors: 2322
@@ -80,7 +80,7 @@ const user: User = {
8080
};
8181
```
8282

83-
Because JavaScript supports classes and object-oriented programming, so does TypeScript - an interface declaration can also be used with classes:
83+
JavaScriptλŠ” ν΄λž˜μŠ€μ™€ 객체 μ§€ν–₯ ν”„λ‘œκ·Έλž˜λ°μ„ μ§€μ›ν•˜κΈ° λ•Œλ¬Έμ—, TypeScript λ˜ν•œ λ™μΌν•©λ‹ˆλ‹€. - μΈν„°νŽ˜μ΄μŠ€λŠ” ν΄λž˜μŠ€λ‘œλ„ μ„ μ–Έν•  수 μžˆμŠ΅λ‹ˆλ‹€.
8484

8585
```ts twoslash
8686
interface User {
@@ -101,7 +101,7 @@ class UserAccount {
101101
const user: User = new UserAccount("Murphy", 1);
102102
```
103103

104-
Interfaces can be used to annotate parameters and return values to functions:
104+
μΈν„°νŽ˜μ΄μŠ€λŠ” ν•¨μˆ˜μ—μ„œ λ§€κ°œλ³€μˆ˜μ™€ 리턴 값을 λͺ…μ‹œν•˜λŠ”λ° μ‚¬μš©λ˜κΈ°λ„ ν•©λ‹ˆλ‹€.
105105

106106
```ts twoslash
107107
// @noErrors
@@ -119,9 +119,9 @@ function deleteUser(user: User) {
119119
}
120120
```
121121

122-
There are already a small set of primitive types available in JavaScript: `boolean`, `bigint`, `null`, `number`, `string`, `symbol`, `object` and `undefined`, which you can use in an interface. TypeScript extends this list with a few more. for example: `any` (allow anything), [`unknown`](/en/play#example/unknown-and-never) (ensure someone using this type declares what the type is), [`never`](/en/play#example/unknown-and-never) (it's not possible that this type could happen) `void` (a function which returns `undefined` or has no return value).
122+
JavaScriptμ—μ„œ μ‚¬μš©ν•  수 μžˆλŠ” 적은 μ’…λ₯˜μ˜ μ›μ‹œ νƒ€μž…μ΄ 이미 μžˆμŠ΅λ‹ˆλ‹€.: `boolean`, `bigint`, `null`, `number`, `string`, `symbol`, `object`와 `undefined`λŠ” μΈν„°νŽ˜μ΄μŠ€μ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. TypeScriptλŠ” λͺ‡ κ°€μ§€λ₯Ό μΆ”κΈ°ν•΄ λͺ©λ‘μ„ ν™•μž₯ν•©λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, `any` (무엇이든 ν—ˆμš©ν•©λ‹ˆλ‹€), [`unknown`](/en/play#example/unknown-and-never) (이 νƒ€μž…μ„ μ‚¬μš©ν•˜λŠ” μ‚¬λžŒμ΄ νƒ€μž…μ΄ 무엇인지 μ„ μ–Έν–ˆλŠ”κ°€λ₯Ό ν™•μΈν•˜μ‹­μ‹œμ˜€), [`never`](/en/play#example/unknown-and-never) (이 νƒ€μž…μ€ λ°œμƒλ  수 μ—†μŠ΅λ‹ˆλ‹€) `void` (`undefined`λ₯Ό λ¦¬ν„΄ν•˜κ±°λ‚˜ 리턴 값이 μ—†λŠ” ν•¨μˆ˜).
123123

124-
You'll see quite quickly that there are two syntaxes for building types: [Interfaces and Types](/play/?e=83#example/types-vs-interfaces) - you should prefer `interface`, and use `type` when you need specific features.
124+
νƒ€μž…μ„ κ΅¬μΆ•ν•˜κΈ° μœ„ν•œ 두 κ°€μ§€ ꡬ문이 μžˆλ‹€λŠ” 것을 κ½€ λΉ λ₯΄κ²Œ μ•Œ 수 μžˆμ„ κ²ƒμž…λ‹ˆλ‹€.: [Interfaces and Types](/play/?e=83#example/types-vs-interfaces) - `interface`λ₯Ό μš°μ„ μ μœΌλ‘œ μ‚¬μš©ν•˜κ³  νŠΉμ • κΈ°λŠ₯이 ν•„μš”ν•  λ•Œ `type`을 μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
125125

126126
## Composing Types
127127

@@ -294,4 +294,4 @@ If the object or class has all the required properties, then TypeScript will say
294294
This doc is a high level 5 minute overview of the sort of syntax and tools you would use in everyday code. From here you should:
295295

296296
* Read the full Handbook [from start to finish](/docs/handbook/intro.html) (30m)
297-
* Explore the [Playground examples](/play#show-examples).
297+
* Explore the [Playground examples](/play#show-examples).

0 commit comments

Comments
Β (0)