@@ -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
441441function 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
451451function 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
466466function length<T extends ArrayLike <unknown >>(t : T ): number {}
467467
468468function 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
480480function 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
498498import { value , Type } from " npm-package" ;
499499import { other , Types } from " ./local-package" ;
500500import * 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
507507import f = require (" single-function-package" );
508508```
509509
510- You can export with an export list :
510+ export ๋ชฉ๋ก์ผ๋ก ๋ด๋ณด๋ผ ์ ์์ต๋๋ค :
511511
512512``` ts
513513export { f };
@@ -518,29 +518,29 @@ function f() {
518518function g() {} // g is not exported
519519```
520520
521- Or by marking each export individually :
521+ ๋๋ ๊ฐ๋ณ์ ์ผ๋ก ํ์ํด์ :
522522
523523``` ts
524524export function f { return g () }
525525function 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
538538const a = [1 , 2 , 3 ];
539539a .push (102 ); // ):
540540a[0 ] = 101 ; // D:
541541```
542542
543- TypeScript additionally has a ` readonly ` modifier for properties .
543+ TypeScript๋ ์ถ๊ฐ์ ์ผ๋ก ํ๋กํผํฐ์ ` readonly ` ์ ์ด์๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค .
544544
545545``` ts
546546interface Rx {
@@ -550,8 +550,8 @@ let rx: Rx = { x: 1 };
550550rx .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
557557interface X {
@@ -561,9 +561,9 @@ let rx: Readonly<X> = { x: 1 };
561561rx .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
569569let a: ReadonlyArray <number > = [1 , 2 , 3 ];
@@ -572,21 +572,21 @@ a.push(102); // error
572572b [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
579579let a = [1 , 2 , 3 ] as const ;
580580a .push (102 ); // error
581581a [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