From 124443b858d24bfbc03b0e552ee8598d7e9f27fb Mon Sep 17 00:00:00 2001 From: "guyeol, jeong" Date: Wed, 2 Sep 2020 18:05:30 +0900 Subject: [PATCH 1/8] =?UTF-8?q?labeled=20tuple=20elements=20=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20=EB=B2=88=EC=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/release-notes/typescript-4.0.md | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index 59e06766..8976c57c 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -190,12 +190,12 @@ Variadic tuple types enable a lot of new exciting patterns, especially around fu We expect we may be able to leverage it to do a better job type-checking JavaScript's built-in `bind` method. A handful of other inference improvements and patterns also went into this, and if you're interested in learning more, you can take a look at [the pull request](https://github.com/microsoft/TypeScript/pull/39094) for variadic tuples. -## Labeled Tuple Elements +## 라벨링된 튜플 요소 (Labeled Tuple Elements) -Improving the experience around tuple types and parameter lists is important because it allows us to get strongly typed validation around common JavaScript idioms - really just slicing and dicing argument lists and passing them to other functions. -The idea that we can use tuple types for rest parameters is one place where this is crucial. +튜플 타입과 매개 변수 목록의 경험을 개선하는 것은 일반적인 JavaScript 관용구에 대한 타입 유효성 검사를 강화시켜주기 때문에 중요합니다 - 실제로 인수 목록을 자르고 다른 함수로 전달만 해주면 됩니다. +나머지 매개 변수(rest parameter)에 튜플 타입을 사용할 수 있다는 생각은 아주 중요합니다. -For example, the following function that uses a tuple type as a rest parameter... +예를 들어, 다음 함수는 튜플 타입을 나머지 매개 변수로 사용한 예시는... ```ts function foo(...args: [string, number]): void { @@ -203,7 +203,7 @@ function foo(...args: [string, number]): void { } ``` -...should appear no different from the following function... +...다음 함수와 다르지 않아야 합니다... ```ts function foo(arg0: string, arg1: number): void { @@ -211,7 +211,7 @@ function foo(arg0: string, arg1: number): void { } ``` -...for any caller of `foo`. +...`foo`의 모든 호출자에 대해서도. ```ts // @errors: 2554 @@ -225,38 +225,38 @@ foo("hello", 42, true); foo("hello"); ``` -There is one place where the differences begin to become observable though: readability. -In the first example, we have no parameter names for the first and second elements. -While these have no impact on type-checking, the lack of labels on tuple positions can make them harder to use - harder to communicate our intent. +그래도 차이점이 보이기 시작한 것은: 가독성입니다. +첫 번째 예시에서는, 첫 번째와 두 번째 요소에 대한 매개 변수 이름이 없습니다. +타입-검사에는 영향이 전혀 없지만, 튜플 위치에 라벨이 없는 것은 사용하기 어렵게 만듭니다 - 의도를 전달하기 어렵습니다. -That's why in TypeScript 4.0, tuples types can now provide labels. +TypeScript 4.0에서 튜플 타입에 라벨을 제공하는 이유입니다. ```ts type Range = [start: number, end: number]; ``` -To deepen the connection between parameter lists and tuple types, the syntax for rest elements and optional elements mirrors the syntax for parameter lists. +매개 변수 목록과 튜플 타입 사이의 연결을 강화하려면, 나머지 요소와 선택적 요소에 대한 구문이 매개 변수 목록의 구문을 반영합니다. ```ts type Foo = [first: number, second?: string, ...rest: any[]]; ``` -There are a few rules when using labeled tuples. -For one, when labeling a tuple element, all other elements in the tuple must also be labeled. +라벨링 된 튜플을 사용할 때는 몇 가지 규칙이 있습니다. +하나는 튜플 요소를 라벨링 할 때, 튜플에 있는 다른 모든 요소들 역시 라벨링 되어야 합니다. ```ts // @errors: 5084 type Bar = [first: string, number]; ``` -It's worth noting - labels don't require us to name our variables differently when destructuring. -They're purely there for documentation and tooling. +당연하게도 - 라벨은 구조 분해할 때 변수 이름을 다르게 지정할 필요가 없습니다. +이것은 순전히 문서화와 도구를 위해 필요합니다. ```ts function foo(x: [first: string, second: number]) { // ... - // note: we didn't need to name these 'first' and 'second' + // 주의: 'first'와 'second'에 대해 이름 지을 필요 없음 const [a, b] = x; a // ^? @@ -265,12 +265,12 @@ function foo(x: [first: string, second: number]) { } ``` -Overall, labeled tuples are handy when taking advantage of patterns around tuples and argument lists, along with implementing overloads in a type-safe way. -In fact, TypeScript's editor support will try to display them as overloads when possible. +전반적으로, 라벨링 된 튜플은 안전한 타입 방식으로 오버로드를 구현하는 것과 튜플과 인수 목록의 패턴을 활용할 때 편리합니다 +사실, TypeScript 에디터 지원은 가능한 경우 오버로드로 표시하려 합니다. -![Signature help displaying a union of labeled tuples as in a parameter list as two signatures](https://devblogs.microsoft.com/typescript/wp-content/uploads/sites/11/2020/08/signatureHelpLabeledTuples.gif) +![라벨링된 튜플의 유니언을 매개변수 목록에서처럼 두 가지 시그니처로 보여주는 시그니처 도움말](https://devblogs.microsoft.com/typescript/wp-content/uploads/sites/11/2020/08/signatureHelpLabeledTuples.gif) -To learn more, check out [the pull request](https://github.com/microsoft/TypeScript/pull/38234) for labeled tuple elements. +더 알고 싶으시면, 라벨링된 튜플 요소에 대한 [풀 리퀘스트](https://github.com/microsoft/TypeScript/pull/38234)를 확인해보세요 ## Class Property Inference from Constructors From 26fd6543f839596236e2abc32fbaa9821d05eb1c Mon Sep 17 00:00:00 2001 From: Seohee Park Date: Sat, 5 Sep 2020 07:01:06 +0900 Subject: [PATCH 2/8] Fix comment --- pages/release-notes/typescript-4.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index 8976c57c..3d05479e 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -259,9 +259,9 @@ function foo(x: [first: string, second: number]) { // 주의: 'first'와 'second'에 대해 이름 지을 필요 없음 const [a, b] = x; a -// ^? +// ^ = const a: string b -// ^? +// ^ = const b: number } ``` From eb7c0c5d70dea8b0b0986dd5cc7c8bc7e9634b02 Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:34:30 +0900 Subject: [PATCH 3/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Kibeom Kwon --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index 3d05479e..acc56b31 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -192,7 +192,7 @@ A handful of other inference improvements and patterns also went into this, and ## 라벨링된 튜플 요소 (Labeled Tuple Elements) -튜플 타입과 매개 변수 목록의 경험을 개선하는 것은 일반적인 JavaScript 관용구에 대한 타입 유효성 검사를 강화시켜주기 때문에 중요합니다 - 실제로 인수 목록을 자르고 다른 함수로 전달만 해주면 됩니다. +튜플 타입과 매개 변수 목록에 대해 개선하는 것은 일반적인 JavaScript 관용구에 대한 타입 유효성 검사를 강화시켜주기 때문에 중요합니다 - 실제로 인수 목록을 자르고 다른 함수로 전달만 해주면 됩니다. 나머지 매개 변수(rest parameter)에 튜플 타입을 사용할 수 있다는 생각은 아주 중요합니다. 예를 들어, 다음 함수는 튜플 타입을 나머지 매개 변수로 사용한 예시는... From 96653cd9830b75eeb383470e151969b74f1469d4 Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:34:37 +0900 Subject: [PATCH 4/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Seohee Park --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index acc56b31..061fba63 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -195,7 +195,7 @@ A handful of other inference improvements and patterns also went into this, and 튜플 타입과 매개 변수 목록에 대해 개선하는 것은 일반적인 JavaScript 관용구에 대한 타입 유효성 검사를 강화시켜주기 때문에 중요합니다 - 실제로 인수 목록을 자르고 다른 함수로 전달만 해주면 됩니다. 나머지 매개 변수(rest parameter)에 튜플 타입을 사용할 수 있다는 생각은 아주 중요합니다. -예를 들어, 다음 함수는 튜플 타입을 나머지 매개 변수로 사용한 예시는... +예를 들어, 튜플 타입을 나머지 매개 변수로 사용하는 다음 함수는... ```ts function foo(...args: [string, number]): void { From 0cf009e80045fba2845d5cf025457e7ddb085363 Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:34:46 +0900 Subject: [PATCH 5/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Seohee Park --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index 061fba63..cc68bee6 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -227,7 +227,7 @@ foo("hello"); 그래도 차이점이 보이기 시작한 것은: 가독성입니다. 첫 번째 예시에서는, 첫 번째와 두 번째 요소에 대한 매개 변수 이름이 없습니다. -타입-검사에는 영향이 전혀 없지만, 튜플 위치에 라벨이 없는 것은 사용하기 어렵게 만듭니다 - 의도를 전달하기 어렵습니다. +타입-검사에는 전혀 영향이 없지만, 튜플 위치에 라벨이 없는 것은 사용하기 어렵게 만듭니다 - 의도를 전달하기 어렵습니다. TypeScript 4.0에서 튜플 타입에 라벨을 제공하는 이유입니다. From 97639396d422bcccbf68b876828bcee2c35620a1 Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:34:52 +0900 Subject: [PATCH 6/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Seohee Park --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index cc68bee6..97d12ca3 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -235,7 +235,7 @@ TypeScript 4.0에서 튜플 타입에 라벨을 제공하는 이유입니다. type Range = [start: number, end: number]; ``` -매개 변수 목록과 튜플 타입 사이의 연결을 강화하려면, 나머지 요소와 선택적 요소에 대한 구문이 매개 변수 목록의 구문을 반영합니다. +매개 변수 목록과 튜플 타입 사이의 연결을 강화하기 위해, 나머지 요소와 선택적 요소에 대한 구문이 매개 변수 목록의 구문을 반영합니다. ```ts type Foo = [first: number, second?: string, ...rest: any[]]; From 8e0e4557a18e3ee86fb2114c6deec84a59420a2f Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:35:00 +0900 Subject: [PATCH 7/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Seohee Park --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index 97d12ca3..d090d2d7 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -265,7 +265,7 @@ function foo(x: [first: string, second: number]) { } ``` -전반적으로, 라벨링 된 튜플은 안전한 타입 방식으로 오버로드를 구현하는 것과 튜플과 인수 목록의 패턴을 활용할 때 편리합니다 +전반적으로, 라벨링 된 튜플은 안전한 타입 방식으로 오버로드를 구현하는 것과 튜플과 인수 목록의 패턴을 활용할 때 편리합니다. 사실, TypeScript 에디터 지원은 가능한 경우 오버로드로 표시하려 합니다. ![라벨링된 튜플의 유니언을 매개변수 목록에서처럼 두 가지 시그니처로 보여주는 시그니처 도움말](https://devblogs.microsoft.com/typescript/wp-content/uploads/sites/11/2020/08/signatureHelpLabeledTuples.gif) From 727a48f460286cf961a329da7948d633ab6657a4 Mon Sep 17 00:00:00 2001 From: GuyeolJeong Date: Mon, 7 Sep 2020 10:35:07 +0900 Subject: [PATCH 8/8] Update pages/release-notes/typescript-4.0.md Co-authored-by: Seohee Park --- pages/release-notes/typescript-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/release-notes/typescript-4.0.md b/pages/release-notes/typescript-4.0.md index d090d2d7..d4acd42d 100644 --- a/pages/release-notes/typescript-4.0.md +++ b/pages/release-notes/typescript-4.0.md @@ -225,7 +225,7 @@ foo("hello", 42, true); foo("hello"); ``` -그래도 차이점이 보이기 시작한 것은: 가독성입니다. +그러나 차이점이 보이기 시작한 부분은: 가독성입니다. 첫 번째 예시에서는, 첫 번째와 두 번째 요소에 대한 매개 변수 이름이 없습니다. 타입-검사에는 전혀 영향이 없지만, 튜플 위치에 라벨이 없는 것은 사용하기 어렵게 만듭니다 - 의도를 전달하기 어렵습니다.