From eddde5dd3876a255a2c3efd99df37598ec45ce09 Mon Sep 17 00:00:00 2001 From: JarvisArt <38420763+JarvisArt@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:08:15 +0800 Subject: [PATCH] chore: update easy readme (#12446) --- questions/00004-easy-pick/README.ja.md | 2 +- questions/00004-easy-pick/README.md | 2 +- questions/00007-easy-readonly/README.ja.md | 2 +- questions/00007-easy-readonly/README.md | 2 +- questions/00011-easy-tuple-to-object/README.ja.md | 2 +- questions/00011-easy-tuple-to-object/README.md | 2 +- questions/00014-easy-first/README.ja.md | 2 +- questions/00014-easy-first/README.md | 2 +- questions/00018-easy-tuple-length/README.ja.md | 2 +- questions/00018-easy-tuple-length/README.md | 2 +- questions/00043-easy-exclude/README.ja.md | 6 ++++++ questions/00043-easy-exclude/README.ko.md | 6 ++++++ questions/00043-easy-exclude/README.md | 6 ++++++ questions/00043-easy-exclude/README.zh-CN.md | 9 ++++++++- questions/00189-easy-awaited/README.ja.md | 9 ++++++++- questions/00189-easy-awaited/README.ko.md | 10 +++++++++- questions/00189-easy-awaited/README.md | 10 +++++++++- questions/00189-easy-awaited/README.zh-CN.md | 8 +++++++- questions/00268-easy-if/README.ja.md | 2 +- questions/00268-easy-if/README.zh-CN.md | 2 +- questions/00533-easy-concat/README.ja.md | 2 +- questions/00533-easy-concat/README.md | 2 +- questions/00533-easy-concat/README.zh-CN.md | 2 +- questions/00898-easy-includes/README.ja.md | 2 +- questions/00898-easy-includes/README.md | 2 +- questions/00898-easy-includes/README.zh-CN.md | 2 +- questions/03057-easy-push/README.ja.md | 2 +- questions/03057-easy-push/README.md | 2 +- questions/03057-easy-push/README.zh-CN.md | 2 +- questions/03060-easy-unshift/README.ja.md | 2 +- questions/03060-easy-unshift/README.md | 2 +- questions/03060-easy-unshift/README.zh-CN.md | 2 +- questions/03312-easy-parameters/README.ja.md | 7 +++++++ questions/03312-easy-parameters/README.ko.md | 7 +++++++ questions/03312-easy-parameters/README.md | 7 +++++++ questions/03312-easy-parameters/README.zh-CN.md | 6 ++++++ 36 files changed, 110 insertions(+), 29 deletions(-) diff --git a/questions/00004-easy-pick/README.ja.md b/questions/00004-easy-pick/README.ja.md index d42ddf5c..507076d3 100644 --- a/questions/00004-easy-pick/README.ja.md +++ b/questions/00004-easy-pick/README.ja.md @@ -2,7 +2,7 @@ 組み込みの型ユーティリティ`Pick`を使用せず、`T`から`K`のプロパティを抽出する型を実装します。 -例えば +例えば: ```ts interface Todo { diff --git a/questions/00004-easy-pick/README.md b/questions/00004-easy-pick/README.md index f7c1b916..763065e3 100644 --- a/questions/00004-easy-pick/README.md +++ b/questions/00004-easy-pick/README.md @@ -4,7 +4,7 @@ Implement the built-in `Pick` generic without using it. Constructs a type by picking the set of properties `K` from `T` -For example +For example: ```ts interface Todo { diff --git a/questions/00007-easy-readonly/README.ja.md b/questions/00007-easy-readonly/README.ja.md index 74b2c4cd..563ebc46 100644 --- a/questions/00007-easy-readonly/README.ja.md +++ b/questions/00007-easy-readonly/README.ja.md @@ -2,7 +2,7 @@ 組み込みの型ユーティリティ`Readonly`を使用せず、`T` のすべてのプロパティを読み取り専用にする型を実装します。実装された型のプロパティは再割り当てできません。 -例えば +例えば: ```ts interface Todo { diff --git a/questions/00007-easy-readonly/README.md b/questions/00007-easy-readonly/README.md index 5a372ee3..a17ef7b8 100644 --- a/questions/00007-easy-readonly/README.md +++ b/questions/00007-easy-readonly/README.md @@ -5,7 +5,7 @@ Implement the built-in `Readonly` generic without using it. Constructs a type with all properties of T set to readonly, meaning the properties of the constructed type cannot be reassigned. -For example +For example: ```ts interface Todo { diff --git a/questions/00011-easy-tuple-to-object/README.ja.md b/questions/00011-easy-tuple-to-object/README.ja.md index 47a482f8..5c5f4866 100644 --- a/questions/00011-easy-tuple-to-object/README.ja.md +++ b/questions/00011-easy-tuple-to-object/README.ja.md @@ -2,7 +2,7 @@ タプルを受け取り、その各値のkey/valueを持つオブジェクトの型に変換する型を実装します。 -例えば +例えば: ```ts const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const diff --git a/questions/00011-easy-tuple-to-object/README.md b/questions/00011-easy-tuple-to-object/README.md index ddb8b551..38752092 100644 --- a/questions/00011-easy-tuple-to-object/README.md +++ b/questions/00011-easy-tuple-to-object/README.md @@ -2,7 +2,7 @@ Give an array, transform into an object type and the key/value must in the given array. -For example +For example: ```ts const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const diff --git a/questions/00014-easy-first/README.ja.md b/questions/00014-easy-first/README.ja.md index 46b0f7d4..d3baca4d 100644 --- a/questions/00014-easy-first/README.ja.md +++ b/questions/00014-easy-first/README.ja.md @@ -2,7 +2,7 @@ 配列`T`を受け取り、その最初のプロパティの型を返す`First`を実装します。 -例えば +例えば: ```ts type arr1 = ['a', 'b', 'c'] diff --git a/questions/00014-easy-first/README.md b/questions/00014-easy-first/README.md index 3514ba99..e8e0b643 100644 --- a/questions/00014-easy-first/README.md +++ b/questions/00014-easy-first/README.md @@ -3,7 +3,7 @@ Implement a generic `First` that takes an Array `T` and returns it's first element's type. -For example +For example: ```ts type arr1 = ['a', 'b', 'c'] diff --git a/questions/00018-easy-tuple-length/README.ja.md b/questions/00018-easy-tuple-length/README.ja.md index 2ab5b25b..aab76a04 100644 --- a/questions/00018-easy-tuple-length/README.ja.md +++ b/questions/00018-easy-tuple-length/README.ja.md @@ -2,7 +2,7 @@ タプル`T`を受け取り、そのタプルの長さを返す型`Length`を実装します。 -例えば +例えば: ```ts type tesla = ['tesla', 'model 3', 'model X', 'model Y'] diff --git a/questions/00018-easy-tuple-length/README.md b/questions/00018-easy-tuple-length/README.md index d5afc1d2..10fa036c 100644 --- a/questions/00018-easy-tuple-length/README.md +++ b/questions/00018-easy-tuple-length/README.md @@ -2,7 +2,7 @@ For given a tuple, you need create a generic `Length`, pick the length of the tuple -For example +For example: ```ts type tesla = ['tesla', 'model 3', 'model X', 'model Y'] diff --git a/questions/00043-easy-exclude/README.ja.md b/questions/00043-easy-exclude/README.ja.md index c9e2caa5..47e4731c 100644 --- a/questions/00043-easy-exclude/README.ja.md +++ b/questions/00043-easy-exclude/README.ja.md @@ -2,4 +2,10 @@ 組み込みの型ユーティリティ`Exclude `を使用せず、`U`に割り当て可能な型を`T`から除外する型を実装します。 +例えば: + +```ts +type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c' +``` +
戻る 解答を共有 解答を確認 diff --git a/questions/00043-easy-exclude/README.ko.md b/questions/00043-easy-exclude/README.ko.md index 56b51d34..c7fb04bf 100644 --- a/questions/00043-easy-exclude/README.ko.md +++ b/questions/00043-easy-exclude/README.ko.md @@ -2,4 +2,10 @@ `T`에서 `U`에 할당할 수 있는 타입을 제외하는 내장 제네릭 `Exclude`를 이를 사용하지 않고 구현하세요. +예시: + +```ts +type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c' +``` +
돌아가기 정답 공유하기 정답 보기 \ No newline at end of file diff --git a/questions/00043-easy-exclude/README.md b/questions/00043-easy-exclude/README.md index fcc78cf0..aed5b007 100644 --- a/questions/00043-easy-exclude/README.md +++ b/questions/00043-easy-exclude/README.md @@ -1,7 +1,13 @@

Exclude easy #built-in

by Zheeeng @zheeeng

Take the Challenge    简体中文 日本語 한국어

Implement the built-in Exclude + > Exclude from T those types that are assignable to U +For example: + +```ts +type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c' +```
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/00043-easy-exclude/README.zh-CN.md b/questions/00043-easy-exclude/README.zh-CN.md index 7dd63aa8..f31435f2 100644 --- a/questions/00043-easy-exclude/README.zh-CN.md +++ b/questions/00043-easy-exclude/README.zh-CN.md @@ -3,6 +3,13 @@ > 欢迎 PR 改进翻译质量。 实现内置的Exclude 类型,但不能直接使用它本身。 ->从联合类型T中排除U的类型成员,来构造一个新的类型。 + +> 从联合类型T中排除U的类型成员,来构造一个新的类型。 + +例如: + +```ts +type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c' +```
返回首页 分享你的解答 查看解答 \ No newline at end of file diff --git a/questions/00189-easy-awaited/README.ja.md b/questions/00189-easy-awaited/README.ja.md index 96455281..b32b8e27 100644 --- a/questions/00189-easy-awaited/README.ja.md +++ b/questions/00189-easy-awaited/README.ja.md @@ -1,7 +1,14 @@

Awaited 初級 #promise #built-in

by Maciej Sikora @maciejsikora

挑戦する    English 简体中文 한국어

Promise ライクな型が内包する型をどのように取得すればよいでしょうか。 -例えば、`Promise`という型がある場合、どのようにして ExampleType を取得すればよいでしょうか。 + +例えば:`Promise`という型がある場合、どのようにして ExampleType を取得すればよいでしょうか。 + +```ts +type ExampleType = Promise + +type Result = // string +``` > この問題の元記事は [original article](https://dev.to/macsikora/advanced-typescript-exercises-question-1-45k4) by [@maciejsikora](https://github.com/maciejsikora) です。 diff --git a/questions/00189-easy-awaited/README.ko.md b/questions/00189-easy-awaited/README.ko.md index fcc78500..40c4271b 100644 --- a/questions/00189-easy-awaited/README.ko.md +++ b/questions/00189-easy-awaited/README.ko.md @@ -1,6 +1,14 @@

Awaited 쉬움 #promise #built-in

by Maciej Sikora @maciejsikora

도전하기    English 简体中文 日本語

-Promise와 같은 타입에 감싸인 타입이 있을 때, 안에 감싸인 타입이 무엇인지 어떻게 알 수 있을까요? 예를 들어 `Promise`이 있을 때, `ExampleType`을 어떻게 얻을 수 있을까요? +Promise와 같은 타입에 감싸인 타입이 있을 때, 안에 감싸인 타입이 무엇인지 어떻게 알 수 있을까요? + +예시: 들어 `Promise`이 있을 때, `ExampleType`을 어떻게 얻을 수 있을까요? + +```ts +type ExampleType = Promise + +type Result = // string +``` > 출처: [original article](https://dev.to/macsikora/advanced-typescript-exercises-question-1-45k4) by [@maciejsikora](https://github.com/maciejsikora) diff --git a/questions/00189-easy-awaited/README.md b/questions/00189-easy-awaited/README.md index fe7657b5..a8ebb606 100644 --- a/questions/00189-easy-awaited/README.md +++ b/questions/00189-easy-awaited/README.md @@ -1,6 +1,14 @@

Awaited easy #promise #built-in

by Maciej Sikora @maciejsikora

Take the Challenge    简体中文 日本語 한국어

-If we have a type which is wrapped type like Promise. How we can get a type which is inside the wrapped type? For example if we have `Promise` how to get ExampleType? +If we have a type which is wrapped type like Promise. How we can get a type which is inside the wrapped type? + +For example: if we have `Promise` how to get ExampleType? + +```ts +type ExampleType = Promise + +type Result = // string +``` > This question is ported from the [original article](https://dev.to/macsikora/advanced-typescript-exercises-question-1-45k4) by [@maciejsikora](https://github.com/maciejsikora) diff --git a/questions/00189-easy-awaited/README.zh-CN.md b/questions/00189-easy-awaited/README.zh-CN.md index 3461be88..516272c9 100644 --- a/questions/00189-easy-awaited/README.zh-CN.md +++ b/questions/00189-easy-awaited/README.zh-CN.md @@ -2,7 +2,13 @@ 假如我们有一个 Promise 对象,这个 Promise 对象会返回一个类型。在 TS 中,我们用 Promise 中的 T 来描述这个 Promise 返回的类型。请你实现一个类型,可以获取这个类型。 -比如:`Promise`,请你返回 ExampleType 类型。 +例如:`Promise`,请你返回 ExampleType 类型。 + +```ts +type ExampleType = Promise + +type Result = // string +``` > 这个挑战来自于 [@maciejsikora](https://github.com/maciejsikora) 的文章:[original article](https://dev.to/macsikora/advanced-typescript-exercises-question-1-45k4) diff --git a/questions/00268-easy-if/README.ja.md b/questions/00268-easy-if/README.ja.md index c904fe81..f7766dc8 100644 --- a/questions/00268-easy-if/README.ja.md +++ b/questions/00268-easy-if/README.ja.md @@ -3,7 +3,7 @@ 条件値`C`、 `C`が truthy である場合の戻り値の型`T`、`C`が falsy である場合の戻り値の型`F`を受け取る`If`を実装します。 条件値`C` は`true`か`false`のどちらかであることが期待されますが、`T` と `F` は任意の型をとることができます。 -例えば +例えば: ```ts type A = If; // expected to be 'a' diff --git a/questions/00268-easy-if/README.zh-CN.md b/questions/00268-easy-if/README.zh-CN.md index 845196cf..fdd28a4a 100644 --- a/questions/00268-easy-if/README.zh-CN.md +++ b/questions/00268-easy-if/README.zh-CN.md @@ -2,7 +2,7 @@ 实现一个 `IF` 类型,它接收一个条件类型 `C` ,一个判断为真时的返回类型 `T` ,以及一个判断为假时的返回类型 `F`。 `C` 只能是 `true` 或者 `false`, `T` 和 `F` 可以是任意类型。 -举例: +例如: ```ts type A = If // expected to be 'a' diff --git a/questions/00533-easy-concat/README.ja.md b/questions/00533-easy-concat/README.ja.md index e727f540..be2ff832 100644 --- a/questions/00533-easy-concat/README.ja.md +++ b/questions/00533-easy-concat/README.ja.md @@ -2,7 +2,7 @@ JavaScript の`Array.concat`関数を型システムに実装します。この型は 2 つの引数を受け取り、受け取ったイテレータの要素を順に含む新しい配列を返します。 -例えば +例えば: ```ts type Result = Concat<[1], [2]>; // expected to be [1, 2] diff --git a/questions/00533-easy-concat/README.md b/questions/00533-easy-concat/README.md index 7adc8ef2..7465163d 100644 --- a/questions/00533-easy-concat/README.md +++ b/questions/00533-easy-concat/README.md @@ -2,7 +2,7 @@ Implement the JavaScript `Array.concat` function in the type system. A type takes the two arguments. The output should be a new array that includes inputs in ltr order -For example +For example: ```ts type Result = Concat<[1], [2]> // expected to be [1, 2] diff --git a/questions/00533-easy-concat/README.zh-CN.md b/questions/00533-easy-concat/README.zh-CN.md index fea46730..436d2b38 100644 --- a/questions/00533-easy-concat/README.zh-CN.md +++ b/questions/00533-easy-concat/README.zh-CN.md @@ -2,7 +2,7 @@ 在类型系统里实现 JavaScript 内置的 `Array.concat` 方法,这个类型接受两个参数,返回的新数组类型应该按照输入参数从左到右的顺序合并为一个新的数组。 -举例, +例如: ```ts type Result = Concat<[1], [2]> // expected to be [1, 2] diff --git a/questions/00898-easy-includes/README.ja.md b/questions/00898-easy-includes/README.ja.md index 732677d8..b1210510 100644 --- a/questions/00898-easy-includes/README.ja.md +++ b/questions/00898-easy-includes/README.ja.md @@ -2,7 +2,7 @@ JavaScriptの`Array.include`関数を型システムに実装します。この型は、2 つの引数を受け取り、`true`や`false`を出力しなければなりません。 -例えば +例えば: ```ts type isPillarMen = Includes<['Kars', 'Esidisi', 'Wamuu', 'Santana'], 'Dio'> // expected to be `false` diff --git a/questions/00898-easy-includes/README.md b/questions/00898-easy-includes/README.md index d311034a..0fad9eb3 100644 --- a/questions/00898-easy-includes/README.md +++ b/questions/00898-easy-includes/README.md @@ -2,7 +2,7 @@ Implement the JavaScript `Array.includes` function in the type system. A type takes the two arguments. The output should be a boolean `true` or `false`. -For example +For example: ```ts type isPillarMen = Includes<['Kars', 'Esidisi', 'Wamuu', 'Santana'], 'Dio'> // expected to be `false` diff --git a/questions/00898-easy-includes/README.zh-CN.md b/questions/00898-easy-includes/README.zh-CN.md index 63189cc3..877b7fa8 100644 --- a/questions/00898-easy-includes/README.zh-CN.md +++ b/questions/00898-easy-includes/README.zh-CN.md @@ -2,7 +2,7 @@ 在类型系统里实现 JavaScript 的 `Array.includes` 方法,这个类型接受两个参数,返回的类型要么是 `true` 要么是 `false`。 -举例来说, +例如: ```ts type isPillarMen = Includes<['Kars', 'Esidisi', 'Wamuu', 'Santana'], 'Dio'> // expected to be `false` diff --git a/questions/03057-easy-push/README.ja.md b/questions/03057-easy-push/README.ja.md index 41313fa7..cb444e71 100644 --- a/questions/03057-easy-push/README.ja.md +++ b/questions/03057-easy-push/README.ja.md @@ -2,7 +2,7 @@ ```Array.push```のジェネリックバージョンを実装します。 -例えば +例えば: ```typescript type Result = Push<[1, 2], '3'> // [1, 2, '3'] diff --git a/questions/03057-easy-push/README.md b/questions/03057-easy-push/README.md index 1d25902a..984b8d5a 100644 --- a/questions/03057-easy-push/README.md +++ b/questions/03057-easy-push/README.md @@ -2,7 +2,7 @@ Implement the generic version of ```Array.push``` -For example +For example: ```typescript type Result = Push<[1, 2], '3'> // [1, 2, '3'] diff --git a/questions/03057-easy-push/README.zh-CN.md b/questions/03057-easy-push/README.zh-CN.md index 08d83cfa..6dfc0018 100644 --- a/questions/03057-easy-push/README.zh-CN.md +++ b/questions/03057-easy-push/README.zh-CN.md @@ -2,7 +2,7 @@ 在类型系统里实现通用的 ```Array.push``` 。 -举例如下, +例如: ```typescript type Result = Push<[1, 2], '3'> // [1, 2, '3'] diff --git a/questions/03060-easy-unshift/README.ja.md b/questions/03060-easy-unshift/README.ja.md index 80058550..8b1103d2 100644 --- a/questions/03060-easy-unshift/README.ja.md +++ b/questions/03060-easy-unshift/README.ja.md @@ -2,7 +2,7 @@ ```Array.unshift```の型バージョンを実装します。 -例えば +例えば: ```typescript type Result = Unshift<[1, 2], 0> // [0, 1, 2,] diff --git a/questions/03060-easy-unshift/README.md b/questions/03060-easy-unshift/README.md index e2571da9..2fa94078 100644 --- a/questions/03060-easy-unshift/README.md +++ b/questions/03060-easy-unshift/README.md @@ -2,7 +2,7 @@ Implement the type version of ```Array.unshift``` -For example +For example: ```typescript type Result = Unshift<[1, 2], 0> // [0, 1, 2,] diff --git a/questions/03060-easy-unshift/README.zh-CN.md b/questions/03060-easy-unshift/README.zh-CN.md index 2711d783..4d21a2b0 100644 --- a/questions/03060-easy-unshift/README.zh-CN.md +++ b/questions/03060-easy-unshift/README.zh-CN.md @@ -2,7 +2,7 @@ 实现类型版本的 ```Array.unshift```。 -举例, +例如: ```typescript type Result = Unshift<[1, 2], 0> // [0, 1, 2,] diff --git a/questions/03312-easy-parameters/README.ja.md b/questions/03312-easy-parameters/README.ja.md index f9d3bfd0..8662ccaf 100644 --- a/questions/03312-easy-parameters/README.ja.md +++ b/questions/03312-easy-parameters/README.ja.md @@ -2,5 +2,12 @@ 組み込みの型ユーティリティ`Parameters`を使用せず、`T`からタプル型を構築する型を実装します。 +例えば: + +```ts +const foo = (arg1: string, arg2: number): void => {} + +type FunctionParamsType = MyParameters // [arg1: string, arg2: number] +```
戻る 解答を共有 解答を確認 \ No newline at end of file diff --git a/questions/03312-easy-parameters/README.ko.md b/questions/03312-easy-parameters/README.ko.md index 74e69a27..a6883cd1 100644 --- a/questions/03312-easy-parameters/README.ko.md +++ b/questions/03312-easy-parameters/README.ko.md @@ -2,5 +2,12 @@ 내장 제네릭 `Parameters`를 이를 사용하지 않고 구현하세요. +예시: + +```ts +const foo = (arg1: string, arg2: number): void => {} + +type FunctionParamsType = MyParameters // [arg1: string, arg2: number] +```
돌아가기 정답 공유하기 정답 보기 \ No newline at end of file diff --git a/questions/03312-easy-parameters/README.md b/questions/03312-easy-parameters/README.md index a248bd5a..e6dfb7b0 100644 --- a/questions/03312-easy-parameters/README.md +++ b/questions/03312-easy-parameters/README.md @@ -2,5 +2,12 @@ Implement the built-in Parameters generic without using it. +For example: + +```ts +const foo = (arg1: string, arg2: number): void => {} + +type FunctionParamsType = MyParameters // [arg1: string, arg2: number] +```
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/03312-easy-parameters/README.zh-CN.md b/questions/03312-easy-parameters/README.zh-CN.md index 24358d22..da7f51c0 100644 --- a/questions/03312-easy-parameters/README.zh-CN.md +++ b/questions/03312-easy-parameters/README.zh-CN.md @@ -2,6 +2,12 @@ 实现内置的 Parameters 类型,而不是直接使用它,可参考[TypeScript官方文档](https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype)。 +例如: +```ts +const foo = (arg1: string, arg2: number): void => {} + +type FunctionParamsType = MyParameters // [arg1: string, arg2: number] +```
返回首页 分享你的解答 查看解答 \ No newline at end of file