Skip to content

Commit 979a0a4

Browse files
annkimm๊น€๋ฏผ์ง€guyeoldvlprsh
authored
docs: to end from Type Parameters #114 (#161)
* docs: fix text * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: Seohee Park <dvlprsh103@gmail.com> * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: GuyeolJeong <jigu8534@gmail.com> * fix lint * Update pages/tutorials/ts-for-functional-programmers.md * Update pages/tutorials/ts-for-functional-programmers.md Co-authored-by: ๊น€๋ฏผ์ง€ <ll@llui-MacBookPro.local> Co-authored-by: GuyeolJeong <jigu8534@gmail.com> Co-authored-by: Seohee Park <dvlprsh103@gmail.com>
1 parent 5374da4 commit 979a0a4

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

โ€Žpages/tutorials/ts-for-functional-programmers.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -432,82 +432,82 @@ function height(s: Shape) {
432432
}
433433
```
434434

435-
## Type Parameters
435+
## ํƒ€์ž… ๋งค๊ฐœ๋ณ€์ˆ˜ (Type Parameters)
436436

437-
Like most C-descended languages, TypeScript requires declaration of
438-
type parameters:
437+
๋Œ€๋ถ€๋ถ„์˜ C-๊ณ„์—ด ์–ธ์–ด์ฒ˜๋Ÿผ, TypeScript๋Š” ํƒ€์ž… ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ์„ ์–ธ์„
438+
์š”๊ตฌํ•ฉ๋‹ˆ๋‹ค:
439439

440440
```ts
441441
function liftArray<T>(t: T): Array<T> {
442442
return [t];
443443
}
444444
```
445445

446-
There is no case requirement, but type parameters are conventionally
447-
single uppercase letters. Type parameters can also be constrained to a
448-
type, which behaves a bit like type class constraints:
446+
๋Œ€์†Œ๋ฌธ์ž์— ๋Œ€ํ•œ ์š”๊ตฌ ์กฐ๊ฑด์€ ์—†์ง€๋งŒ, ํƒ€์ž… ๋งค๊ฐœ ๋ณ€์ˆ˜๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋‹จ์ผ ๋Œ€๋ฌธ์ž์ž…๋‹ˆ๋‹ค.
447+
ํƒ€์ž… ๋งค๊ฐœ ๋ณ€์ˆ˜๋Š” ํƒ€์ž… ํด๋ž˜์Šค ์ œ์•ฝ๊ณผ ๋น„์Šทํ•˜๊ฒŒ ๋™์ž‘ํ•˜๋Š”
448+
ํƒ€์ž…์œผ๋กœ ์ œํ•œ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
449449

450450
```ts
451451
function firstish<T extends { length: number }>(t1: T, t2: T): T {
452452
return t1.length > t2.length ? t1 : t2;
453453
}
454454
```
455455

456-
TypeScript can usually infer type arguments from a call based on the
457-
type of the arguments, so type arguments are usually not needed.
456+
TypeScript๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ์ธ์ž ํƒ€์ž…์— ๊ธฐ๋ฐ˜ํ•˜์—ฌ ํ˜ธ์ถœ๋กœ๋ถ€ํ„ฐ ํƒ€์ž… ์ธ์ž๋ฅผ ์ถ”๋ก ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—
457+
๋Œ€๊ฒŒ ํƒ€์ž… ์ธ์ž๋ฅผ ํ•„์š”๋กœ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
458458

459-
Because TypeScript is structural, it doesn't need type parameters as
460-
much as nominal systems. Specifically, they are not needed to make a
461-
function polymorphic. Type parameters should only be used to
462-
_propagate_ type information, such as constraining parameters to be
463-
the same type:
459+
์™œ๋ƒํ•˜๋ฉด TypeScript๋Š” ๊ตฌ์กฐ์ ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์ด๋ฆ„ ๊ธฐ๋ฐ˜์˜ ์‹œ์Šคํ…œ๋งŒํผ ํƒ€์ž… ๋งค๊ฐœ ๋ณ€์ˆ˜๋ฅผ ํ•„์š”๋กœ
460+
ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ํ•จ์ˆ˜๋ฅผ ๋‹คํ˜•์„ฑ์œผ๋กœ ๋งŒ๋“ค
461+
ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค. ํƒ€์ž… ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๊ฐ™์€ ํƒ€์ž…์œผ๋กœ
462+
์ œํ•œํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ํƒ€์ž… ์ •๋ณด๋ฅผ _์ „ํŒŒํ•˜๋Š”๋ฐ๋งŒ_
463+
์“ฐ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค:
464464

465465
```ts
466466
function length<T extends ArrayLike<unknown>>(t: T): number {}
467467

468468
function length(t: ArrayLike<unknown>): number {}
469469
```
470470

471-
In the first `length`, T is not necessary; notice that it's only
472-
referenced once, so it's not being used to constrain the type of the
473-
return value or other parameters.
471+
์ฒซ ๋ฒˆ์งธ `length`์—์„œ T๋Š” ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค; ์˜ค์ง ํ•œ ๋ฒˆ๋งŒ ์ฐธ์กฐ๋˜๋ฉฐ,
472+
๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜๋‚˜ ๋ฆฌํ„ด ๊ฐ’์˜ ํƒ€์ž…์„ ์ œํ•œํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์„
473+
์•Œ์•„๋‘ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
474474

475-
### Higher-kinded types
475+
### ์ƒ์œ„ ์œ ํ˜•์˜ ํƒ€์ž… (Higher-kinded types)
476476

477-
TypeScript does not have higher kinded types, so the following is not legal:
477+
TypeScript๋Š” ์ƒ์œ„ ์œ ํ˜•์˜ ํƒ€์ž…์ด ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•˜๋Š” ๊ฑด ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค:
478478

479479
```ts
480480
function length<T extends ArrayLike<unknown>, U>(m: T<U>) {}
481481
```
482482

483-
### Point-free programming
483+
### ํฌ์ธํŠธ-ํ”„๋ฆฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ (Point-free programming)
484484

485-
Point-free programming &mdash; heavy use of currying and function
486-
composition &mdash; is possible in JavaScript, but can be verbose.
487-
In TypeScript, type inference often fails for point-free programs, so
488-
you'll end up specifying type parameters instead of value parameters. The
489-
result is so verbose that it's usually better to avoid point-free
490-
programming.
485+
ํฌ์ธํŠธ-ํ”„๋ฆฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์€ &mdash; ์ปค๋ง ๋ฐ ํ•จ์ˆ˜ ํ•ฉ์„ฑ์˜ ๊ณผ๋„ํ•œ ์‚ฌ์šฉ
486+
&mdash; JavaScript์—์„œ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์žฅํ™ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
487+
TypeScript์—์„œ ํฌ์ธํŠธ-ํ”„๋ฆฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์— ๋Œ€ํ•œ ํƒ€์ž… ์ถ”๋ก ์ด ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์œผ๋ฏ€๋กœ,
488+
๊ฐ’ ๋งค๊ฐœ๋ณ€์ˆ˜ ๋Œ€์‹  ํƒ€์ž… ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ง€์ •ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
489+
๊ทธ ๊ฒฐ๊ณผ๋Š” ๋„ˆ๋ฌด ์žฅํ™ฉํ•ด์„œ ๋ณดํ†ต ํฌ์ธํŠธ-ํ”„๋ฆฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์€ ํ”ผํ•˜๋Š” ๊ฒŒ
490+
์ข‹์Šต๋‹ˆ๋‹ค.
491491

492-
## Module system
492+
## ๋ชจ๋“ˆ ์‹œ์Šคํ…œ (Module system)
493493

494-
JavaScript's modern module syntax is a bit like Haskell's, except that
495-
any file with `import` or `export` is implicitly a module:
494+
`import` ๋˜๋Š” `export`๊ฐ€ ํฌํ•จ๋œ ํŒŒ์ผ์ด ์•”์‹œ์ ์œผ๋กœ ๋ชจ๋“ˆ์ด๋ผ๋Š” ์ ์„ ์ œ์™ธํ•˜๋ฉด
495+
JavaScript์˜ ์ตœ์‹  ๋ชจ๋“ˆ ๊ตฌ๋ฌธ์€ Haskell๊ณผ ์•ฝ๊ฐ„ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค:
496496

497497
```ts
498498
import { value, Type } from "npm-package";
499499
import { other, Types } from "./local-package";
500500
import * as prefix from "../lib/third-package";
501501
```
502502

503-
You can also import commonjs modules &mdash; modules written using node.js'
504-
module system:
503+
commonjs ๋ชจ๋“ˆ๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค &mdash; node.js' ๋ชจ๋“ˆ ์‹œ์Šคํ…œ์œผ๋กœ
504+
์‚ฌ์šฉ๋œ ๋ชจ๋“ˆ:
505505

506506
```ts
507507
import f = require("single-function-package");
508508
```
509509

510-
You can export with an export list:
510+
export ๋ชฉ๋ก์œผ๋กœ ๋‚ด๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
511511

512512
```ts
513513
export { f };
@@ -518,29 +518,29 @@ function f() {
518518
function g() {} // g is not exported
519519
```
520520

521-
Or by marking each export individually:
521+
๋˜๋Š” ๊ฐœ๋ณ„์ ์œผ๋กœ ํ‘œ์‹œํ•ด์„œ:
522522

523523
```ts
524524
export function f { return g() }
525525
function g() { }
526526
```
527527

528-
The latter style is more common but both are allowed, even in the same
529-
file.
528+
ํ›„์ž์˜ ์Šคํƒ€์ผ์ด ๋” ์ผ๋ฐ˜์ ์ด์ง€๋งŒ ๊ฐ™์€ ํŒŒ์ผ ๋‚ด์—์„œ๋„ ๋‘˜ ๋‹ค
529+
ํ—ˆ์šฉ๋ฉ๋‹ˆ๋‹ค.
530530

531-
## `readonly` and `const`
531+
## `readonly` ์™€ `const` (`readonly` and `const`)
532532

533-
In JavaScript, mutability is the default, although it allows variable
534-
declarations with `const` to declare that the _reference_ is
535-
immutable. The referent is still mutable:
533+
JavaScript์—์„œ, ์ˆ˜์ • ๊ฐ€๋Šฅํ•จ์ด ๊ธฐ๋ณธ์ด์ง€๋งŒ,
534+
_์ฐธ์กฐ_๊ฐ€ ์ˆ˜์ • ๋ถˆ๊ฐ€๋Šฅํ•จ์„ ์„ ์–ธํ•˜๊ธฐ ์œ„ํ•ด `const`๋กœ ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
535+
์ฐธ์กฐ ๋Œ€์ƒ์€ ์—ฌ์ „ํžˆ ์ˆ˜์ • ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค:
536536

537537
```js
538538
const a = [1, 2, 3];
539539
a.push(102); // ):
540540
a[0] = 101; // D:
541541
```
542542

543-
TypeScript additionally has a `readonly` modifier for properties.
543+
TypeScript๋Š” ์ถ”๊ฐ€์ ์œผ๋กœ ํ”„๋กœํผํ‹ฐ์— `readonly` ์ œ์–ด์ž๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
544544

545545
```ts
546546
interface Rx {
@@ -550,8 +550,8 @@ let rx: Rx = { x: 1 };
550550
rx.x = 12; // error
551551
```
552552

553-
It also ships with a mapped type `Readonly<T>` that makes
554-
all properties `readonly`:
553+
๋งคํ•‘๋œ ํƒ€์ž… `Readonly<T>` ์€ ๋ชจ๋“  ํ”„๋กœํผํ‹ฐ๋ฅผ `readonly` ์œผ๋กœ
554+
๋งŒ๋“ค์–ด ๋ฒ„๋ฆฝ๋‹ˆ๋‹ค:
555555

556556
```ts
557557
interface X {
@@ -561,9 +561,9 @@ let rx: Readonly<X> = { x: 1 };
561561
rx.x = 12; // error
562562
```
563563

564-
And it has a specific `ReadonlyArray<T>` type that removes
565-
side-affecting methods and prevents writing to indices of the array,
566-
as well as special syntax for this type:
564+
๊ทธ๋ฆฌ๊ณ  ๋ถ€์ž‘์šฉ์„ ์ผ์œผํ‚ค๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋ฐฐ์—ด ์ธ๋ฑ์Šค์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ์„ ๋ฐฉ์ง€ํ•˜๋Š”
565+
ํŠน์ • `ReadonlyArray<T>` ํƒ€์ž…๊ณผ,
566+
์ด ํƒ€์ž…์— ๋Œ€ํ•œ ํŠน์ˆ˜ ๊ตฌ๋ฌธ์ด ์žˆ์Šต๋‹ˆ๋‹ค:
567567

568568
```ts
569569
let a: ReadonlyArray<number> = [1, 2, 3];
@@ -572,21 +572,21 @@ a.push(102); // error
572572
b[0] = 101; // error
573573
```
574574

575-
You can also use a const-assertion, which operates on arrays and
576-
object literals:
575+
๋ฐฐ์—ด๊ณผ ๊ฐ์ฒด ๋ฆฌํ„ฐ๋Ÿด์—์„œ ๋™์ž‘ํ•˜๋Š” const-assertion๋งŒ
576+
์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
577577

578578
```ts
579579
let a = [1, 2, 3] as const;
580580
a.push(102); // error
581581
a[0] = 101; // error
582582
```
583583

584-
However, none of these options are the default, so they are not
585-
consistently used in TypeScript code.
584+
๊ทธ๋Ÿฌ๋‚˜ ์ด๋Ÿฌํ•œ ๊ธฐ๋Šฅ๋“ค์€ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋Šฅ์ด ์•„๋‹ˆ๋ฏ€๋กœ TypeScript ์ฝ”๋“œ์—
585+
์ผ๊ด€์ ์œผ๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋ฉ๋‹ˆ๋‹ค.
586586

587-
## Next Steps
587+
## ๋‹ค์Œ ๋‹จ๊ณ„ (Next Steps)
588588

589-
This doc is a high level overview of the syntax and types you would use in everyday code. From here you should:
589+
์ด ๋ฌธ์„œ๋Š” ์ผ์ƒ์ ์ธ ์ฝ”๋“œ์—์„œ ๋†’์€ ์ˆ˜์ค€์˜ ๊ตฌ๋ฌธ๊ณผ ํƒ€์ž…์— ๋Œ€ํ•œ ๊ฐœ์š”๋ฅผ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋ถ€ํ„ฐ๋Š” ์•„๋ž˜๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค:
590590

591-
*-* Read the full Handbook [from start to finish](/docs/handbook/intro.html) (30m)
592-
*-* Explore the [Playground examples](/play#show-examples).
591+
*-* ์ „์ฒด ํ•ธ๋“œ๋ถ์„ [์ฒ˜์Œ๋ถ€ํ„ฐ ๋๊นŒ์ง€](/docs/handbook/intro.html) ์ฝ์œผ์„ธ์š” (30m)
592+
*-* [Playground ์˜ˆ์‹œ](/play#show-examples)๋ฅผ ๋ณด์„ธ์š”.

0 commit comments

Comments
ย (0)