diff --git a/.vscode/i18n-ally-custom-framework.yml b/.vscode/i18n-ally-custom-framework.yml index 53d5a33b3..ea6bacf77 100644 --- a/.vscode/i18n-ally-custom-framework.yml +++ b/.vscode/i18n-ally-custom-framework.yml @@ -15,7 +15,7 @@ usageMatchRegex: # The following example shows how to detect `t("your.i18n.keys")` # the `{key}` will be placed by a proper keypath matching regex, # you can ignore it and use your own matching rules as well - - 't\(\w+?, [''"`]({key})[''"`]\)' + - '[^\w]t\(\w+?, [''"`]({key})[''"`]\)' # An array of strings containing refactor templates. # The "$1" will be replaced by the keypath specified. diff --git a/README.ja.md b/README.ja.md index 2d443b747..110339460 100644 --- a/README.ja.md +++ b/README.ja.md @@ -32,7 +32,7 @@ TypeScriptには [ts-toolbelt](https://github.com/millsp/ts-toolbelt), [utility- > 以下のバッジをクリックすると、課題の詳細が表示されます。 -1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・文字の組み合わせ 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

お試し (1)

初級 (13)

中級 (69)

上級 (34)

最上級 (14)


+1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・文字の組み合わせ 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

お試し (1)

初級 (13)

中級 (69)

上級 (34)

最上級 (14)


> ✨ [今後の課題](https://github.com/type-challenges/type-challenges/issues?q=is%3Aissue+is%3Aopen+label%3Anew-challenge) diff --git a/README.ko.md b/README.ko.md index 3eb76993e..6c9d808eb 100644 --- a/README.ko.md +++ b/README.ko.md @@ -30,7 +30,7 @@ > 배지를 클릭해서 챌린지의 자세한 내용을 확인해보세요. -1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

워밍업 (1)

쉬움 (13)

보통 (69)

어려움 (34)

매우 어려움 (14)


+1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

워밍업 (1)

쉬움 (13)

보통 (69)

어려움 (34)

매우 어려움 (14)


> ✨ [Upcoming challenges](https://github.com/type-challenges/type-challenges/issues?q=is%3Aissue+is%3Aopen+label%3Anew-challenge) diff --git a/README.md b/README.md index 0291fdefe..cec1d8e67 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This project is aimed at helping you better understand how the type system works > Click the following badges to see details of the challenges. -1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

warm-up (1)

easy (13)

medium (69)

hard (34)

extreme (14)


+1
13・Hello World

13
4・Pick 7・Readonly 11・Tuple to Object 14・First of Array 18・Length of Tuple 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・Get Return Type 3・Omit 8・Readonly 2 9・Deep Readonly 10・Tuple to Union 12・Chainable Options 15・Last of Array 16・Pop 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・Append Argument 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・Fibonacci Sequence 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・Without 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・Simple Vue 17・Currying 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・Get Readonly Keys 151・Query String Parser 216・Slice 274・Integers Comparator 462・Currying 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・Chainable Options 8767・Combination 6・Simple Vue 213・Vue Basic Props
#arguments191・Append Argument 3196・Flip Arguments
#array14・First of Array 533・Concat 898・Includes 3057・Push 3060・Unshift 15・Last of Array 16・Pop 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5117・Without 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・Currying 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・Pick 7・Readonly 43・Exclude 189・Awaited 3312・Parameters 2・Get Return Type 3・Omit 20・Promise.all
#deep9・Deep Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・Get Return Type 10・Tuple to Union 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・Readonly 8・Readonly 2 9・Deep Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・Get Readonly Keys
#promise189・Awaited
#readonly7・Readonly 8・Readonly 2 9・Deep Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・Simple Vue 1290・Pinia
#tuple18・Length of Tuple 3312・Parameters 10・Tuple to Union 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・Pick 3・Omit 10・Tuple to Union 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 5117・Without 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・Get Readonly Keys
#vue6・Simple Vue 213・Vue Basic Props 1290・Pinia
          

By Plain Text

warm-up (1)

easy (13)

medium (69)

hard (34)

extreme (14)


> ✨ [Upcoming challenges](https://github.com/type-challenges/type-challenges/issues?q=is%3Aissue+is%3Aopen+label%3Anew-challenge) diff --git a/README.zh-CN.md b/README.zh-CN.md index 0131f301d..b4b1e1bca 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -33,7 +33,7 @@ > 点击下方徽章查看题目内容 -1
13・Hello World

13
4・实现 Pick 7・实现 Readonly 11・元组转换为对象 14・第一个元素 18・获取元组长度 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・获取函数返回类型 3・实现 Omit 8・Readonly 2 9・深度 Readonly 10・元组转合集 12・可串联构造器 15・最后一个元素 16・出堆 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・追加参数 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・斐波那契序列 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・去除数组指定元素 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・简单的 Vue 类型 17・柯里化 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・获取只读字段 151・Query String Parser 216・Slice 274・Integers Comparator 462・柯里化 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・可串联构造器 8767・Combination 6・简单的 Vue 类型 213・Vue Basic Props
#arguments191・追加参数 3196・Flip Arguments
#array14・第一个元素 533・Concat 898・Includes 3057・Push 3060・Unshift 15・最后一个元素 16・出堆 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・柯里化 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・实现 Pick 7・实现 Readonly 43・Exclude 189・Awaited 3312・Parameters 2・获取函数返回类型 3・实现 Omit 20・Promise.all
#deep9・深度 Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・获取函数返回类型 10・元组转合集 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・实现 Readonly 8・Readonly 2 9・深度 Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・获取只读字段
#promise189・Awaited
#readonly7・实现 Readonly 8・Readonly 2 9・深度 Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・简单的 Vue 类型 1290・Pinia
#tuple18・获取元组长度 3312・Parameters 10・元组转合集 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・实现 Pick 3・实现 Omit 10・元组转合集 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・获取只读字段
#vue6・简单的 Vue 类型 213・Vue Basic Props 1290・Pinia
#数组5117・去除数组指定元素
#联合类型5117・去除数组指定元素
          

By Plain Text

热身 (1)

简单 (13)

中等 (69)

困难 (34)

地狱 (14)


+1
13・Hello World

13
4・实现 Pick 7・实现 Readonly 11・元组转换为对象 14・第一个元素 18・获取元组长度 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

69
2・获取函数返回类型 3・实现 Omit 8・Readonly 2 9・深度 Readonly 10・元组转合集 12・可串联构造器 15・最后一个元素 16・出堆 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・追加参数 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 610・CamelCase 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・斐波那契序列 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・去除数组指定元素 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7258・ObjectKeyPaths 7544・Construct Tuple 8640・Number Range 8767・Combination

34
6・简单的 Vue 类型 17・柯里化 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths

14
5・获取只读字段 151・Query String Parser 216・Slice 274・Integers Comparator 462・柯里化 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract
By Tags
#application12・可串联构造器 8767・Combination 6・简单的 Vue 类型 213・Vue Basic Props
#arguments191・追加参数 3196・Flip Arguments
#array14・第一个元素 533・Concat 898・Includes 3057・Push 3060・Unshift 15・最后一个元素 16・出堆 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 17・柯里化 1 2822・Split 5423・Intersection 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・实现 Pick 7・实现 Readonly 43・Exclude 189・Awaited 3312・Parameters 2・获取函数返回类型 3・实现 Omit 20・Promise.all
#deep9・深度 Readonly 553・Deep object to unique 956・DeepPick
#infer3312・Parameters 2・获取函数返回类型 10・元组转合集 2070・Drop Char 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 6141・Binary to Decimal 274・Integers Comparator 476・Sum 517・Multiply
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries
#object-keys7・实现 Readonly 8・Readonly 2 9・深度 Readonly 527・Append to object 2793・Mutable 7258・ObjectKeyPaths 7258・Object Key Paths 5・获取只读字段
#promise189・Awaited
#readonly7・实现 Readonly 8・Readonly 2 9・深度 Readonly 2793・Mutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 2822・Split 4037・IsPalindrome
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 610・CamelCase 612・KebabCase 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 5140・Trunc 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・简单的 Vue 类型 1290・Pinia
#tuple18・获取元组长度 3312・Parameters 10・元组转合集 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・实现 Pick 3・实现 Omit 10・元组转合集 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 3326・BEM style string 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・获取只读字段
#vue6・简单的 Vue 类型 213・Vue Basic Props 1290・Pinia
#数组5117・去除数组指定元素
#联合类型5117・去除数组指定元素
          

By Plain Text

热身 (1)

简单 (13)

中等 (69)

困难 (34)

地狱 (14)


> ✨ [即将到来的新题目](https://github.com/type-challenges/type-challenges/issues?q=is%3Aissue+is%3Aopen+label%3Anew-challenge) diff --git a/questions/2-medium-return-type/README.ja.md b/questions/00002-medium-return-type/README.ja.md similarity index 100% rename from questions/2-medium-return-type/README.ja.md rename to questions/00002-medium-return-type/README.ja.md diff --git a/questions/2-medium-return-type/README.ko.md b/questions/00002-medium-return-type/README.ko.md similarity index 100% rename from questions/2-medium-return-type/README.ko.md rename to questions/00002-medium-return-type/README.ko.md diff --git a/questions/2-medium-return-type/README.md b/questions/00002-medium-return-type/README.md similarity index 100% rename from questions/2-medium-return-type/README.md rename to questions/00002-medium-return-type/README.md diff --git a/questions/2-medium-return-type/README.zh-CN.md b/questions/00002-medium-return-type/README.zh-CN.md similarity index 100% rename from questions/2-medium-return-type/README.zh-CN.md rename to questions/00002-medium-return-type/README.zh-CN.md diff --git a/questions/2-medium-return-type/info.yml b/questions/00002-medium-return-type/info.yml similarity index 100% rename from questions/2-medium-return-type/info.yml rename to questions/00002-medium-return-type/info.yml diff --git a/questions/2-medium-return-type/info.zh-CN.yml b/questions/00002-medium-return-type/info.zh-CN.yml similarity index 100% rename from questions/2-medium-return-type/info.zh-CN.yml rename to questions/00002-medium-return-type/info.zh-CN.yml diff --git a/questions/2-medium-return-type/template.ts b/questions/00002-medium-return-type/template.ts similarity index 100% rename from questions/2-medium-return-type/template.ts rename to questions/00002-medium-return-type/template.ts diff --git a/questions/2-medium-return-type/test-cases.ts b/questions/00002-medium-return-type/test-cases.ts similarity index 100% rename from questions/2-medium-return-type/test-cases.ts rename to questions/00002-medium-return-type/test-cases.ts diff --git a/questions/3-medium-omit/README.ja.md b/questions/00003-medium-omit/README.ja.md similarity index 91% rename from questions/3-medium-omit/README.ja.md rename to questions/00003-medium-omit/README.ja.md index 3dae409df..c74e3df21 100644 --- a/questions/3-medium-omit/README.ja.md +++ b/questions/00003-medium-omit/README.ja.md @@ -18,4 +18,4 @@ const todo: TodoPreview = { } ``` -
戻る 解答を共有 解答を確認

関連する課題

4・Pick \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

4・Pick \ No newline at end of file diff --git a/questions/3-medium-omit/README.ko.md b/questions/00003-medium-omit/README.ko.md similarity index 90% rename from questions/3-medium-omit/README.ko.md rename to questions/00003-medium-omit/README.ko.md index d035993db..fe63c644b 100644 --- a/questions/3-medium-omit/README.ko.md +++ b/questions/00003-medium-omit/README.ko.md @@ -18,4 +18,4 @@ const todo: TodoPreview = { } ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

4・Pick \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

4・Pick \ No newline at end of file diff --git a/questions/3-medium-omit/README.md b/questions/00003-medium-omit/README.md similarity index 91% rename from questions/3-medium-omit/README.md rename to questions/00003-medium-omit/README.md index f2d836512..d640d7314 100644 --- a/questions/3-medium-omit/README.md +++ b/questions/00003-medium-omit/README.md @@ -20,4 +20,4 @@ const todo: TodoPreview = { } ``` -
Back Share your Solutions Check out Solutions

Related Challenges

4・Pick \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

4・Pick \ No newline at end of file diff --git a/questions/3-medium-omit/README.zh-CN.md b/questions/00003-medium-omit/README.zh-CN.md similarity index 89% rename from questions/3-medium-omit/README.zh-CN.md rename to questions/00003-medium-omit/README.zh-CN.md index 9784ee945..4c7e32364 100644 --- a/questions/3-medium-omit/README.zh-CN.md +++ b/questions/00003-medium-omit/README.zh-CN.md @@ -20,4 +20,4 @@ const todo: TodoPreview = { } ``` -
返回首页 分享你的解答 查看解答

相关挑战

4・实现 Pick +
返回首页 分享你的解答 查看解答

相关挑战

4・实现 Pick diff --git a/questions/3-medium-omit/info.yml b/questions/00003-medium-omit/info.yml similarity index 100% rename from questions/3-medium-omit/info.yml rename to questions/00003-medium-omit/info.yml diff --git a/questions/3-medium-omit/info.zh-CN.yml b/questions/00003-medium-omit/info.zh-CN.yml similarity index 100% rename from questions/3-medium-omit/info.zh-CN.yml rename to questions/00003-medium-omit/info.zh-CN.yml diff --git a/questions/3-medium-omit/template.ts b/questions/00003-medium-omit/template.ts similarity index 100% rename from questions/3-medium-omit/template.ts rename to questions/00003-medium-omit/template.ts diff --git a/questions/3-medium-omit/test-cases.ts b/questions/00003-medium-omit/test-cases.ts similarity index 100% rename from questions/3-medium-omit/test-cases.ts rename to questions/00003-medium-omit/test-cases.ts diff --git a/questions/4-easy-pick/README.ja.md b/questions/00004-easy-pick/README.ja.md similarity index 91% rename from questions/4-easy-pick/README.ja.md rename to questions/00004-easy-pick/README.ja.md index 9ef70e580..3ec31a260 100644 --- a/questions/4-easy-pick/README.ja.md +++ b/questions/00004-easy-pick/README.ja.md @@ -19,4 +19,4 @@ const todo: TodoPreview = { } ``` -
戻る 解答を共有 解答を確認

関連する課題

3・Omit +
戻る 解答を共有 解答を確認

関連する課題

3・Omit diff --git a/questions/4-easy-pick/README.ko.md b/questions/00004-easy-pick/README.ko.md similarity index 90% rename from questions/4-easy-pick/README.ko.md rename to questions/00004-easy-pick/README.ko.md index 14b17bca0..0e788672b 100644 --- a/questions/4-easy-pick/README.ko.md +++ b/questions/00004-easy-pick/README.ko.md @@ -19,4 +19,4 @@ const todo: TodoPreview = { } ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

3・Omit +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

3・Omit diff --git a/questions/4-easy-pick/README.md b/questions/00004-easy-pick/README.md similarity index 91% rename from questions/4-easy-pick/README.md rename to questions/00004-easy-pick/README.md index 34c1916bc..99e90e64c 100644 --- a/questions/4-easy-pick/README.md +++ b/questions/00004-easy-pick/README.md @@ -21,4 +21,4 @@ const todo: TodoPreview = { } ``` -
Back Share your Solutions Check out Solutions

Related Challenges

3・Omit +
Back Share your Solutions Check out Solutions

Related Challenges

3・Omit diff --git a/questions/4-easy-pick/README.zh-CN.md b/questions/00004-easy-pick/README.zh-CN.md similarity index 89% rename from questions/4-easy-pick/README.zh-CN.md rename to questions/00004-easy-pick/README.zh-CN.md index a1474b76b..6adbf4621 100644 --- a/questions/4-easy-pick/README.zh-CN.md +++ b/questions/00004-easy-pick/README.zh-CN.md @@ -23,4 +23,4 @@ const todo: TodoPreview = { } ``` -
返回首页 分享你的解答 查看解答

相关挑战

3・实现 Omit +
返回首页 分享你的解答 查看解答

相关挑战

3・实现 Omit diff --git a/questions/4-easy-pick/info.yml b/questions/00004-easy-pick/info.yml similarity index 100% rename from questions/4-easy-pick/info.yml rename to questions/00004-easy-pick/info.yml diff --git a/questions/4-easy-pick/info.zh-CN.yml b/questions/00004-easy-pick/info.zh-CN.yml similarity index 100% rename from questions/4-easy-pick/info.zh-CN.yml rename to questions/00004-easy-pick/info.zh-CN.yml diff --git a/questions/4-easy-pick/template.ts b/questions/00004-easy-pick/template.ts similarity index 100% rename from questions/4-easy-pick/template.ts rename to questions/00004-easy-pick/template.ts diff --git a/questions/4-easy-pick/test-cases.ts b/questions/00004-easy-pick/test-cases.ts similarity index 100% rename from questions/4-easy-pick/test-cases.ts rename to questions/00004-easy-pick/test-cases.ts diff --git a/questions/5-extreme-readonly-keys/README.ja.md b/questions/00005-extreme-readonly-keys/README.ja.md similarity index 100% rename from questions/5-extreme-readonly-keys/README.ja.md rename to questions/00005-extreme-readonly-keys/README.ja.md diff --git a/questions/5-extreme-readonly-keys/README.md b/questions/00005-extreme-readonly-keys/README.md similarity index 100% rename from questions/5-extreme-readonly-keys/README.md rename to questions/00005-extreme-readonly-keys/README.md diff --git a/questions/5-extreme-readonly-keys/README.zh-CN.md b/questions/00005-extreme-readonly-keys/README.zh-CN.md similarity index 100% rename from questions/5-extreme-readonly-keys/README.zh-CN.md rename to questions/00005-extreme-readonly-keys/README.zh-CN.md diff --git a/questions/5-extreme-readonly-keys/info.yml b/questions/00005-extreme-readonly-keys/info.yml similarity index 100% rename from questions/5-extreme-readonly-keys/info.yml rename to questions/00005-extreme-readonly-keys/info.yml diff --git a/questions/5-extreme-readonly-keys/info.zh-CN.yml b/questions/00005-extreme-readonly-keys/info.zh-CN.yml similarity index 100% rename from questions/5-extreme-readonly-keys/info.zh-CN.yml rename to questions/00005-extreme-readonly-keys/info.zh-CN.yml diff --git a/questions/5-extreme-readonly-keys/template.ts b/questions/00005-extreme-readonly-keys/template.ts similarity index 100% rename from questions/5-extreme-readonly-keys/template.ts rename to questions/00005-extreme-readonly-keys/template.ts diff --git a/questions/5-extreme-readonly-keys/test-cases.ts b/questions/00005-extreme-readonly-keys/test-cases.ts similarity index 100% rename from questions/5-extreme-readonly-keys/test-cases.ts rename to questions/00005-extreme-readonly-keys/test-cases.ts diff --git a/questions/6-hard-simple-vue/README.ja.md b/questions/00006-hard-simple-vue/README.ja.md similarity index 93% rename from questions/6-hard-simple-vue/README.ja.md rename to questions/00006-hard-simple-vue/README.ja.md index eca33b797..b6af84733 100644 --- a/questions/6-hard-simple-vue/README.ja.md +++ b/questions/00006-hard-simple-vue/README.ja.md @@ -36,4 +36,4 @@ const instance = SimpleVue({ }) ``` -
戻る 解答を共有 解答を確認

関連する課題

213・Vue Basic Props \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

213・Vue Basic Props \ No newline at end of file diff --git a/questions/6-hard-simple-vue/README.md b/questions/00006-hard-simple-vue/README.md similarity index 92% rename from questions/6-hard-simple-vue/README.md rename to questions/00006-hard-simple-vue/README.md index 95fc7e8c7..31dd6a98f 100644 --- a/questions/6-hard-simple-vue/README.md +++ b/questions/00006-hard-simple-vue/README.md @@ -36,4 +36,4 @@ const instance = SimpleVue({ }) ``` -
Back Share your Solutions Check out Solutions

Related Challenges

213・Vue Basic Props +
Back Share your Solutions Check out Solutions

Related Challenges

213・Vue Basic Props diff --git a/questions/6-hard-simple-vue/README.zh-CN.md b/questions/00006-hard-simple-vue/README.zh-CN.md similarity index 92% rename from questions/6-hard-simple-vue/README.zh-CN.md rename to questions/00006-hard-simple-vue/README.zh-CN.md index dd8381455..667de7cb4 100644 --- a/questions/6-hard-simple-vue/README.zh-CN.md +++ b/questions/00006-hard-simple-vue/README.zh-CN.md @@ -36,4 +36,4 @@ const instance = SimpleVue({ }) ``` -
返回首页 分享你的解答 查看解答

相关挑战

213・Vue Basic Props +
返回首页 分享你的解答 查看解答

相关挑战

213・Vue Basic Props diff --git a/questions/6-hard-simple-vue/info.yml b/questions/00006-hard-simple-vue/info.yml similarity index 100% rename from questions/6-hard-simple-vue/info.yml rename to questions/00006-hard-simple-vue/info.yml diff --git a/questions/6-hard-simple-vue/info.zh-CN.yml b/questions/00006-hard-simple-vue/info.zh-CN.yml similarity index 100% rename from questions/6-hard-simple-vue/info.zh-CN.yml rename to questions/00006-hard-simple-vue/info.zh-CN.yml diff --git a/questions/6-hard-simple-vue/template.ts b/questions/00006-hard-simple-vue/template.ts similarity index 100% rename from questions/6-hard-simple-vue/template.ts rename to questions/00006-hard-simple-vue/template.ts diff --git a/questions/6-hard-simple-vue/test-cases.ts b/questions/00006-hard-simple-vue/test-cases.ts similarity index 100% rename from questions/6-hard-simple-vue/test-cases.ts rename to questions/00006-hard-simple-vue/test-cases.ts diff --git a/questions/7-easy-readonly/README.ja.md b/questions/00007-easy-readonly/README.ja.md similarity index 83% rename from questions/7-easy-readonly/README.ja.md rename to questions/00007-easy-readonly/README.ja.md index 139579673..5c5f53c9a 100644 --- a/questions/7-easy-readonly/README.ja.md +++ b/questions/00007-easy-readonly/README.ja.md @@ -19,4 +19,4 @@ todo.title = "Hello" // Error: cannot reassign a readonly property todo.description = "barFoo" // Error: cannot reassign a readonly property ``` -
戻る 解答を共有 解答を確認

関連する課題

8・Readonly 2 9・Deep Readonly +
戻る 解答を共有 解答を確認

関連する課題

8・Readonly 2 9・Deep Readonly diff --git a/questions/7-easy-readonly/README.ko.md b/questions/00007-easy-readonly/README.ko.md similarity index 82% rename from questions/7-easy-readonly/README.ko.md rename to questions/00007-easy-readonly/README.ko.md index e3a9e332b..5f003db52 100644 --- a/questions/7-easy-readonly/README.ko.md +++ b/questions/00007-easy-readonly/README.ko.md @@ -19,4 +19,4 @@ todo.title = "Hello" // Error: cannot reassign a readonly property todo.description = "barFoo" // Error: cannot reassign a readonly property ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

8・Readonly 2 9・Deep Readonly \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

8・Readonly 2 9・Deep Readonly \ No newline at end of file diff --git a/questions/7-easy-readonly/README.md b/questions/00007-easy-readonly/README.md similarity index 83% rename from questions/7-easy-readonly/README.md rename to questions/00007-easy-readonly/README.md index 330b66cef..0eb67d631 100644 --- a/questions/7-easy-readonly/README.md +++ b/questions/00007-easy-readonly/README.md @@ -22,4 +22,4 @@ todo.title = "Hello" // Error: cannot reassign a readonly property todo.description = "barFoo" // Error: cannot reassign a readonly property ``` -
Back Share your Solutions Check out Solutions

Related Challenges

8・Readonly 2 9・Deep Readonly \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

8・Readonly 2 9・Deep Readonly \ No newline at end of file diff --git a/questions/7-easy-readonly/README.zh-CN.md b/questions/00007-easy-readonly/README.zh-CN.md similarity index 82% rename from questions/7-easy-readonly/README.zh-CN.md rename to questions/00007-easy-readonly/README.zh-CN.md index 53eff9d4c..034801805 100644 --- a/questions/7-easy-readonly/README.zh-CN.md +++ b/questions/00007-easy-readonly/README.zh-CN.md @@ -25,4 +25,4 @@ todo.title = "Hello" // Error: cannot reassign a readonly property todo.description = "barFoo" // Error: cannot reassign a readonly property ``` -
返回首页 分享你的解答 查看解答

相关挑战

8・Readonly 2 9・深度 Readonly \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

8・Readonly 2 9・深度 Readonly \ No newline at end of file diff --git a/questions/7-easy-readonly/info.yml b/questions/00007-easy-readonly/info.yml similarity index 100% rename from questions/7-easy-readonly/info.yml rename to questions/00007-easy-readonly/info.yml diff --git a/questions/7-easy-readonly/info.zh-CN.yml b/questions/00007-easy-readonly/info.zh-CN.yml similarity index 100% rename from questions/7-easy-readonly/info.zh-CN.yml rename to questions/00007-easy-readonly/info.zh-CN.yml diff --git a/questions/7-easy-readonly/template.ts b/questions/00007-easy-readonly/template.ts similarity index 100% rename from questions/7-easy-readonly/template.ts rename to questions/00007-easy-readonly/template.ts diff --git a/questions/7-easy-readonly/test-cases.ts b/questions/00007-easy-readonly/test-cases.ts similarity index 100% rename from questions/7-easy-readonly/test-cases.ts rename to questions/00007-easy-readonly/test-cases.ts diff --git a/questions/8-medium-readonly-2/README.ja.md b/questions/00008-medium-readonly-2/README.ja.md similarity index 84% rename from questions/8-medium-readonly-2/README.ja.md rename to questions/00008-medium-readonly-2/README.ja.md index 0db4d9436..c7c7f1811 100644 --- a/questions/8-medium-readonly-2/README.ja.md +++ b/questions/00008-medium-readonly-2/README.ja.md @@ -24,4 +24,4 @@ todo.description = "barFoo" // Error: cannot reassign a readonly property todo.completed = true // OK ``` -
戻る 解答を共有 解答を確認

関連する課題

7・Readonly 9・Deep Readonly \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

7・Readonly 9・Deep Readonly \ No newline at end of file diff --git a/questions/8-medium-readonly-2/README.ko.md b/questions/00008-medium-readonly-2/README.ko.md similarity index 83% rename from questions/8-medium-readonly-2/README.ko.md rename to questions/00008-medium-readonly-2/README.ko.md index cbc73338a..a1cdec4d6 100644 --- a/questions/8-medium-readonly-2/README.ko.md +++ b/questions/00008-medium-readonly-2/README.ko.md @@ -22,4 +22,4 @@ todo.description = "barFoo" // Error: cannot reassign a readonly property todo.completed = true // OK ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

7・Readonly 9・Deep Readonly \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

7・Readonly 9・Deep Readonly \ No newline at end of file diff --git a/questions/8-medium-readonly-2/README.md b/questions/00008-medium-readonly-2/README.md similarity index 83% rename from questions/8-medium-readonly-2/README.md rename to questions/00008-medium-readonly-2/README.md index e8b35c791..b9bbaeca8 100644 --- a/questions/8-medium-readonly-2/README.md +++ b/questions/00008-medium-readonly-2/README.md @@ -24,4 +24,4 @@ todo.description = "barFoo" // Error: cannot reassign a readonly property todo.completed = true // OK ``` -
Back Share your Solutions Check out Solutions

Related Challenges

7・Readonly 9・Deep Readonly \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

7・Readonly 9・Deep Readonly \ No newline at end of file diff --git a/questions/8-medium-readonly-2/README.zh-CN.md b/questions/00008-medium-readonly-2/README.zh-CN.md similarity index 82% rename from questions/8-medium-readonly-2/README.zh-CN.md rename to questions/00008-medium-readonly-2/README.zh-CN.md index 1d28f6a96..f343dccb1 100644 --- a/questions/8-medium-readonly-2/README.zh-CN.md +++ b/questions/00008-medium-readonly-2/README.zh-CN.md @@ -26,4 +26,4 @@ todo.description = "barFoo" // Error: cannot reassign a readonly property todo.completed = true // OK ``` -
返回首页 分享你的解答 查看解答

相关挑战

7・实现 Readonly 9・深度 Readonly \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

7・实现 Readonly 9・深度 Readonly \ No newline at end of file diff --git a/questions/8-medium-readonly-2/info.yml b/questions/00008-medium-readonly-2/info.yml similarity index 100% rename from questions/8-medium-readonly-2/info.yml rename to questions/00008-medium-readonly-2/info.yml diff --git a/questions/8-medium-readonly-2/info.zh-CN.yml b/questions/00008-medium-readonly-2/info.zh-CN.yml similarity index 100% rename from questions/8-medium-readonly-2/info.zh-CN.yml rename to questions/00008-medium-readonly-2/info.zh-CN.yml diff --git a/questions/8-medium-readonly-2/template.ts b/questions/00008-medium-readonly-2/template.ts similarity index 100% rename from questions/8-medium-readonly-2/template.ts rename to questions/00008-medium-readonly-2/template.ts diff --git a/questions/8-medium-readonly-2/test-cases.ts b/questions/00008-medium-readonly-2/test-cases.ts similarity index 100% rename from questions/8-medium-readonly-2/test-cases.ts rename to questions/00008-medium-readonly-2/test-cases.ts diff --git a/questions/9-medium-deep-readonly/README.ja.md b/questions/00009-medium-deep-readonly/README.ja.md similarity index 85% rename from questions/9-medium-deep-readonly/README.ja.md rename to questions/00009-medium-deep-readonly/README.ja.md index 364924e9c..122fe6e73 100644 --- a/questions/9-medium-deep-readonly/README.ja.md +++ b/questions/00009-medium-deep-readonly/README.ja.md @@ -26,4 +26,4 @@ type Expected = { type Todo = DeepReadonly // should be same as `Expected` ``` -
戻る 解答を共有 解答を確認

関連する課題

7・Readonly 8・Readonly 2 \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

7・Readonly 8・Readonly 2 \ No newline at end of file diff --git a/questions/9-medium-deep-readonly/README.ko.md b/questions/00009-medium-deep-readonly/README.ko.md similarity index 83% rename from questions/9-medium-deep-readonly/README.ko.md rename to questions/00009-medium-deep-readonly/README.ko.md index 0745510a2..ab73c0709 100644 --- a/questions/9-medium-deep-readonly/README.ko.md +++ b/questions/00009-medium-deep-readonly/README.ko.md @@ -26,4 +26,4 @@ type Expected = { type Todo = DeepReadonly // should be same as `Expected` ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

7・Readonly 8・Readonly 2 +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

7・Readonly 8・Readonly 2 diff --git a/questions/9-medium-deep-readonly/README.md b/questions/00009-medium-deep-readonly/README.md similarity index 84% rename from questions/9-medium-deep-readonly/README.md rename to questions/00009-medium-deep-readonly/README.md index 058251d99..0e38696cd 100644 --- a/questions/9-medium-deep-readonly/README.md +++ b/questions/00009-medium-deep-readonly/README.md @@ -26,4 +26,4 @@ type Expected = { type Todo = DeepReadonly // should be same as `Expected` ``` -
Back Share your Solutions Check out Solutions

Related Challenges

7・Readonly 8・Readonly 2 +
Back Share your Solutions Check out Solutions

Related Challenges

7・Readonly 8・Readonly 2 diff --git a/questions/9-medium-deep-readonly/README.zh-CN.md b/questions/00009-medium-deep-readonly/README.zh-CN.md similarity index 82% rename from questions/9-medium-deep-readonly/README.zh-CN.md rename to questions/00009-medium-deep-readonly/README.zh-CN.md index 6aaacbbc7..0892db247 100644 --- a/questions/9-medium-deep-readonly/README.zh-CN.md +++ b/questions/00009-medium-deep-readonly/README.zh-CN.md @@ -28,4 +28,4 @@ type Expected = { type Todo = DeepReadonly // should be same as `Expected` ``` -
返回首页 分享你的解答 查看解答

相关挑战

7・实现 Readonly 8・Readonly 2 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

7・实现 Readonly 8・Readonly 2 \ No newline at end of file diff --git a/questions/9-medium-deep-readonly/info.yml b/questions/00009-medium-deep-readonly/info.yml similarity index 100% rename from questions/9-medium-deep-readonly/info.yml rename to questions/00009-medium-deep-readonly/info.yml diff --git a/questions/9-medium-deep-readonly/info.zh-CN.yml b/questions/00009-medium-deep-readonly/info.zh-CN.yml similarity index 100% rename from questions/9-medium-deep-readonly/info.zh-CN.yml rename to questions/00009-medium-deep-readonly/info.zh-CN.yml diff --git a/questions/9-medium-deep-readonly/template.ts b/questions/00009-medium-deep-readonly/template.ts similarity index 100% rename from questions/9-medium-deep-readonly/template.ts rename to questions/00009-medium-deep-readonly/template.ts diff --git a/questions/9-medium-deep-readonly/test-cases.ts b/questions/00009-medium-deep-readonly/test-cases.ts similarity index 100% rename from questions/9-medium-deep-readonly/test-cases.ts rename to questions/00009-medium-deep-readonly/test-cases.ts diff --git a/questions/10-medium-tuple-to-union/README.ja.md b/questions/00010-medium-tuple-to-union/README.ja.md similarity index 67% rename from questions/10-medium-tuple-to-union/README.ja.md rename to questions/00010-medium-tuple-to-union/README.ja.md index 8a68678fb..7b9d442df 100644 --- a/questions/10-medium-tuple-to-union/README.ja.md +++ b/questions/00010-medium-tuple-to-union/README.ja.md @@ -10,4 +10,4 @@ type Arr = ['1', '2', '3'] type Test = TupleToUnion // expected to be '1' | '2' | '3' ``` -
戻る 解答を共有 解答を確認

関連する課題

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/10-medium-tuple-to-union/README.ko.md b/questions/00010-medium-tuple-to-union/README.ko.md similarity index 65% rename from questions/10-medium-tuple-to-union/README.ko.md rename to questions/00010-medium-tuple-to-union/README.ko.md index a3fb94464..743876ad8 100644 --- a/questions/10-medium-tuple-to-union/README.ko.md +++ b/questions/00010-medium-tuple-to-union/README.ko.md @@ -10,4 +10,4 @@ type Arr = ['1', '2', '3'] type Test = TupleToUnion // expected to be '1' | '2' | '3' ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/10-medium-tuple-to-union/README.md b/questions/00010-medium-tuple-to-union/README.md similarity index 64% rename from questions/10-medium-tuple-to-union/README.md rename to questions/00010-medium-tuple-to-union/README.md index 6abf22288..b24c69696 100644 --- a/questions/10-medium-tuple-to-union/README.md +++ b/questions/00010-medium-tuple-to-union/README.md @@ -10,4 +10,4 @@ type Arr = ['1', '2', '3'] type Test = TupleToUnion // expected to be '1' | '2' | '3' ``` -
Back Share your Solutions Check out Solutions

Related Challenges

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/10-medium-tuple-to-union/README.zh-CN.md b/questions/00010-medium-tuple-to-union/README.zh-CN.md similarity index 65% rename from questions/10-medium-tuple-to-union/README.zh-CN.md rename to questions/00010-medium-tuple-to-union/README.zh-CN.md index 2b8e61ac3..1a3f79b79 100644 --- a/questions/10-medium-tuple-to-union/README.zh-CN.md +++ b/questions/00010-medium-tuple-to-union/README.zh-CN.md @@ -10,4 +10,4 @@ type Arr = ['1', '2', '3'] type Test = TupleToUnion // expected to be '1' | '2' | '3' ``` -
返回首页 分享你的解答 查看解答

相关挑战

11・元组转换为对象 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object +
返回首页 分享你的解答 查看解答

相关挑战

11・元组转换为对象 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object diff --git a/questions/10-medium-tuple-to-union/info.yml b/questions/00010-medium-tuple-to-union/info.yml similarity index 100% rename from questions/10-medium-tuple-to-union/info.yml rename to questions/00010-medium-tuple-to-union/info.yml diff --git a/questions/10-medium-tuple-to-union/info.zh-CN.yml b/questions/00010-medium-tuple-to-union/info.zh-CN.yml similarity index 100% rename from questions/10-medium-tuple-to-union/info.zh-CN.yml rename to questions/00010-medium-tuple-to-union/info.zh-CN.yml diff --git a/questions/10-medium-tuple-to-union/template.ts b/questions/00010-medium-tuple-to-union/template.ts similarity index 100% rename from questions/10-medium-tuple-to-union/template.ts rename to questions/00010-medium-tuple-to-union/template.ts diff --git a/questions/10-medium-tuple-to-union/test-cases.ts b/questions/00010-medium-tuple-to-union/test-cases.ts similarity index 100% rename from questions/10-medium-tuple-to-union/test-cases.ts rename to questions/00010-medium-tuple-to-union/test-cases.ts diff --git a/questions/11-easy-tuple-to-object/README.ja.md b/questions/00011-easy-tuple-to-object/README.ja.md similarity index 67% rename from questions/11-easy-tuple-to-object/README.ja.md rename to questions/00011-easy-tuple-to-object/README.ja.md index 6c42aec4c..b90b1db9f 100644 --- a/questions/11-easy-tuple-to-object/README.ja.md +++ b/questions/00011-easy-tuple-to-object/README.ja.md @@ -10,4 +10,4 @@ const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} ``` -
戻る 解答を共有 解答を確認

関連する課題

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object +
戻る 解答を共有 解答を確認

関連する課題

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object diff --git a/questions/11-easy-tuple-to-object/README.ko.md b/questions/00011-easy-tuple-to-object/README.ko.md similarity index 64% rename from questions/11-easy-tuple-to-object/README.ko.md rename to questions/00011-easy-tuple-to-object/README.ko.md index 384571f4c..31ed9b196 100644 --- a/questions/11-easy-tuple-to-object/README.ko.md +++ b/questions/00011-easy-tuple-to-object/README.ko.md @@ -10,4 +10,4 @@ const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/11-easy-tuple-to-object/README.md b/questions/00011-easy-tuple-to-object/README.md similarity index 63% rename from questions/11-easy-tuple-to-object/README.md rename to questions/00011-easy-tuple-to-object/README.md index f3eae590a..72abf49e8 100644 --- a/questions/11-easy-tuple-to-object/README.md +++ b/questions/00011-easy-tuple-to-object/README.md @@ -10,4 +10,4 @@ const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} ``` -
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object +
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object diff --git a/questions/11-easy-tuple-to-object/README.zh-CN.md b/questions/00011-easy-tuple-to-object/README.zh-CN.md similarity index 64% rename from questions/11-easy-tuple-to-object/README.zh-CN.md rename to questions/00011-easy-tuple-to-object/README.zh-CN.md index fca7a3933..6b380fbdb 100644 --- a/questions/11-easy-tuple-to-object/README.zh-CN.md +++ b/questions/00011-easy-tuple-to-object/README.zh-CN.md @@ -12,4 +12,4 @@ const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} ``` -
返回首页 分享你的解答 查看解答

相关挑战

10・元组转合集 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object +
返回首页 分享你的解答 查看解答

相关挑战

10・元组转合集 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object diff --git a/questions/11-easy-tuple-to-object/info.yml b/questions/00011-easy-tuple-to-object/info.yml similarity index 100% rename from questions/11-easy-tuple-to-object/info.yml rename to questions/00011-easy-tuple-to-object/info.yml diff --git a/questions/11-easy-tuple-to-object/info.zh-CN.yml b/questions/00011-easy-tuple-to-object/info.zh-CN.yml similarity index 100% rename from questions/11-easy-tuple-to-object/info.zh-CN.yml rename to questions/00011-easy-tuple-to-object/info.zh-CN.yml diff --git a/questions/11-easy-tuple-to-object/template.ts b/questions/00011-easy-tuple-to-object/template.ts similarity index 100% rename from questions/11-easy-tuple-to-object/template.ts rename to questions/00011-easy-tuple-to-object/template.ts diff --git a/questions/11-easy-tuple-to-object/test-cases.ts b/questions/00011-easy-tuple-to-object/test-cases.ts similarity index 100% rename from questions/11-easy-tuple-to-object/test-cases.ts rename to questions/00011-easy-tuple-to-object/test-cases.ts diff --git a/questions/12-medium-chainable-options/README.ja.md b/questions/00012-medium-chainable-options/README.ja.md similarity index 100% rename from questions/12-medium-chainable-options/README.ja.md rename to questions/00012-medium-chainable-options/README.ja.md diff --git a/questions/12-medium-chainable-options/README.md b/questions/00012-medium-chainable-options/README.md similarity index 100% rename from questions/12-medium-chainable-options/README.md rename to questions/00012-medium-chainable-options/README.md diff --git a/questions/12-medium-chainable-options/README.zh-CN.md b/questions/00012-medium-chainable-options/README.zh-CN.md similarity index 100% rename from questions/12-medium-chainable-options/README.zh-CN.md rename to questions/00012-medium-chainable-options/README.zh-CN.md diff --git a/questions/12-medium-chainable-options/info.yml b/questions/00012-medium-chainable-options/info.yml similarity index 100% rename from questions/12-medium-chainable-options/info.yml rename to questions/00012-medium-chainable-options/info.yml diff --git a/questions/12-medium-chainable-options/info.zh-CN.yml b/questions/00012-medium-chainable-options/info.zh-CN.yml similarity index 100% rename from questions/12-medium-chainable-options/info.zh-CN.yml rename to questions/00012-medium-chainable-options/info.zh-CN.yml diff --git a/questions/12-medium-chainable-options/template.ts b/questions/00012-medium-chainable-options/template.ts similarity index 100% rename from questions/12-medium-chainable-options/template.ts rename to questions/00012-medium-chainable-options/template.ts diff --git a/questions/12-medium-chainable-options/test-cases.ts b/questions/00012-medium-chainable-options/test-cases.ts similarity index 100% rename from questions/12-medium-chainable-options/test-cases.ts rename to questions/00012-medium-chainable-options/test-cases.ts diff --git a/questions/13-warm-hello-world/README.ja.md b/questions/00013-warm-hello-world/README.ja.md similarity index 100% rename from questions/13-warm-hello-world/README.ja.md rename to questions/00013-warm-hello-world/README.ja.md diff --git a/questions/13-warm-hello-world/README.md b/questions/00013-warm-hello-world/README.md similarity index 100% rename from questions/13-warm-hello-world/README.md rename to questions/00013-warm-hello-world/README.md diff --git a/questions/13-warm-hello-world/README.zh-CN.md b/questions/00013-warm-hello-world/README.zh-CN.md similarity index 100% rename from questions/13-warm-hello-world/README.zh-CN.md rename to questions/00013-warm-hello-world/README.zh-CN.md diff --git a/questions/13-warm-hello-world/info.yml b/questions/00013-warm-hello-world/info.yml similarity index 100% rename from questions/13-warm-hello-world/info.yml rename to questions/00013-warm-hello-world/info.yml diff --git a/questions/13-warm-hello-world/template.ts b/questions/00013-warm-hello-world/template.ts similarity index 100% rename from questions/13-warm-hello-world/template.ts rename to questions/00013-warm-hello-world/template.ts diff --git a/questions/13-warm-hello-world/test-cases.ts b/questions/00013-warm-hello-world/test-cases.ts similarity index 100% rename from questions/13-warm-hello-world/test-cases.ts rename to questions/00013-warm-hello-world/test-cases.ts diff --git a/questions/14-easy-first/README.ja.md b/questions/00014-easy-first/README.ja.md similarity index 90% rename from questions/14-easy-first/README.ja.md rename to questions/00014-easy-first/README.ja.md index 4645d83a7..f2fe52564 100644 --- a/questions/14-easy-first/README.ja.md +++ b/questions/00014-easy-first/README.ja.md @@ -12,4 +12,4 @@ type head1 = First // expected to be 'a' type head2 = First // expected to be 3 ``` -
戻る 解答を共有 解答を確認

関連する課題

15・Last of Array +
戻る 解答を共有 解答を確認

関連する課題

15・Last of Array diff --git a/questions/14-easy-first/README.ko.md b/questions/00014-easy-first/README.ko.md similarity index 88% rename from questions/14-easy-first/README.ko.md rename to questions/00014-easy-first/README.ko.md index 25d7fc72b..bc4d2145f 100644 --- a/questions/14-easy-first/README.ko.md +++ b/questions/00014-easy-first/README.ko.md @@ -12,4 +12,4 @@ type head1 = First // expected to be 'a' type head2 = First // expected to be 3 ``` -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

15・Last of Array \ No newline at end of file +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

15・Last of Array \ No newline at end of file diff --git a/questions/14-easy-first/README.md b/questions/00014-easy-first/README.md similarity index 89% rename from questions/14-easy-first/README.md rename to questions/00014-easy-first/README.md index 76c3b86a1..3da6744dd 100644 --- a/questions/14-easy-first/README.md +++ b/questions/00014-easy-first/README.md @@ -13,4 +13,4 @@ type head1 = First // expected to be 'a' type head2 = First // expected to be 3 ``` -
Back Share your Solutions Check out Solutions

Related Challenges

15・Last of Array \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

15・Last of Array \ No newline at end of file diff --git a/questions/14-easy-first/README.zh-CN.md b/questions/00014-easy-first/README.zh-CN.md similarity index 87% rename from questions/14-easy-first/README.zh-CN.md rename to questions/00014-easy-first/README.zh-CN.md index d174152aa..00d5940af 100644 --- a/questions/14-easy-first/README.zh-CN.md +++ b/questions/00014-easy-first/README.zh-CN.md @@ -14,4 +14,4 @@ type head1 = First // expected to be 'a' type head2 = First // expected to be 3 ``` -
返回首页 分享你的解答 查看解答

相关挑战

15・最后一个元素 +
返回首页 分享你的解答 查看解答

相关挑战

15・最后一个元素 diff --git a/questions/14-easy-first/info.yml b/questions/00014-easy-first/info.yml similarity index 100% rename from questions/14-easy-first/info.yml rename to questions/00014-easy-first/info.yml diff --git a/questions/14-easy-first/info.zh-CN.yml b/questions/00014-easy-first/info.zh-CN.yml similarity index 100% rename from questions/14-easy-first/info.zh-CN.yml rename to questions/00014-easy-first/info.zh-CN.yml diff --git a/questions/14-easy-first/template.ts b/questions/00014-easy-first/template.ts similarity index 100% rename from questions/14-easy-first/template.ts rename to questions/00014-easy-first/template.ts diff --git a/questions/14-easy-first/test-cases.ts b/questions/00014-easy-first/test-cases.ts similarity index 100% rename from questions/14-easy-first/test-cases.ts rename to questions/00014-easy-first/test-cases.ts diff --git a/questions/15-medium-last/README.ja.md b/questions/00015-medium-last/README.ja.md similarity index 81% rename from questions/15-medium-last/README.ja.md rename to questions/00015-medium-last/README.ja.md index 56f1483e5..af18cb557 100644 --- a/questions/15-medium-last/README.ja.md +++ b/questions/00015-medium-last/README.ja.md @@ -14,4 +14,4 @@ type tail1 = Last // expected to be 'c' type tail2 = Last // expected to be 1 ``` -
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 16・Pop \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 16・Pop \ No newline at end of file diff --git a/questions/15-medium-last/README.md b/questions/00015-medium-last/README.md similarity index 80% rename from questions/15-medium-last/README.md rename to questions/00015-medium-last/README.md index 56af99b0f..0abf67437 100644 --- a/questions/15-medium-last/README.md +++ b/questions/00015-medium-last/README.md @@ -14,4 +14,4 @@ type tail1 = Last // expected to be 'c' type tail2 = Last // expected to be 1 ``` -
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 16・Pop +
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 16・Pop diff --git a/questions/15-medium-last/README.zh-CN.md b/questions/00015-medium-last/README.zh-CN.md similarity index 78% rename from questions/15-medium-last/README.zh-CN.md rename to questions/00015-medium-last/README.zh-CN.md index aab268e44..4462e1011 100644 --- a/questions/15-medium-last/README.zh-CN.md +++ b/questions/00015-medium-last/README.zh-CN.md @@ -16,4 +16,4 @@ type tail1 = Last // expected to be 'c' type tail2 = Last // expected to be 1 ``` -
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 16・出堆 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 16・出堆 \ No newline at end of file diff --git a/questions/15-medium-last/info.yml b/questions/00015-medium-last/info.yml similarity index 100% rename from questions/15-medium-last/info.yml rename to questions/00015-medium-last/info.yml diff --git a/questions/15-medium-last/info.zh-CN.yml b/questions/00015-medium-last/info.zh-CN.yml similarity index 100% rename from questions/15-medium-last/info.zh-CN.yml rename to questions/00015-medium-last/info.zh-CN.yml diff --git a/questions/15-medium-last/template.ts b/questions/00015-medium-last/template.ts similarity index 100% rename from questions/15-medium-last/template.ts rename to questions/00015-medium-last/template.ts diff --git a/questions/15-medium-last/test-cases.ts b/questions/00015-medium-last/test-cases.ts similarity index 100% rename from questions/15-medium-last/test-cases.ts rename to questions/00015-medium-last/test-cases.ts diff --git a/questions/16-medium-pop/README.ja.md b/questions/00016-medium-pop/README.ja.md similarity index 81% rename from questions/16-medium-pop/README.ja.md rename to questions/00016-medium-pop/README.ja.md index 393ae4046..3adf829d9 100644 --- a/questions/16-medium-pop/README.ja.md +++ b/questions/00016-medium-pop/README.ja.md @@ -16,4 +16,4 @@ type re2 = Pop // expected to be [3, 2] **おまけ**: 同様に `Shift`、 `Push`、 `Unshift` も実装できますか? -
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 15・Last of Array \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 15・Last of Array \ No newline at end of file diff --git a/questions/16-medium-pop/README.md b/questions/00016-medium-pop/README.md similarity index 80% rename from questions/16-medium-pop/README.md rename to questions/00016-medium-pop/README.md index 1a7ee22bf..363bbc660 100644 --- a/questions/16-medium-pop/README.md +++ b/questions/00016-medium-pop/README.md @@ -16,4 +16,4 @@ type re2 = Pop // expected to be [3, 2] **Extra**: Similarly, can you implement `Shift`, `Push` and `Unshift` as well? -
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 15・Last of Array \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 15・Last of Array \ No newline at end of file diff --git a/questions/16-medium-pop/README.zh-CN.md b/questions/00016-medium-pop/README.zh-CN.md similarity index 77% rename from questions/16-medium-pop/README.zh-CN.md rename to questions/00016-medium-pop/README.zh-CN.md index 245555a29..05d41bfcc 100644 --- a/questions/16-medium-pop/README.zh-CN.md +++ b/questions/00016-medium-pop/README.zh-CN.md @@ -18,4 +18,4 @@ type re2 = Pop // expected to be [3, 2] **额外**:同样,您也可以实现`Shift`,`Push`和`Unshift`吗? -
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 15・最后一个元素 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 15・最后一个元素 \ No newline at end of file diff --git a/questions/16-medium-pop/info.yml b/questions/00016-medium-pop/info.yml similarity index 100% rename from questions/16-medium-pop/info.yml rename to questions/00016-medium-pop/info.yml diff --git a/questions/16-medium-pop/info.zh-CN.yml b/questions/00016-medium-pop/info.zh-CN.yml similarity index 100% rename from questions/16-medium-pop/info.zh-CN.yml rename to questions/00016-medium-pop/info.zh-CN.yml diff --git a/questions/16-medium-pop/template.ts b/questions/00016-medium-pop/template.ts similarity index 100% rename from questions/16-medium-pop/template.ts rename to questions/00016-medium-pop/template.ts diff --git a/questions/16-medium-pop/test-cases.ts b/questions/00016-medium-pop/test-cases.ts similarity index 100% rename from questions/16-medium-pop/test-cases.ts rename to questions/00016-medium-pop/test-cases.ts diff --git a/questions/17-hard-currying-1/README.ja.md b/questions/00017-hard-currying-1/README.ja.md similarity index 77% rename from questions/17-hard-currying-1/README.ja.md rename to questions/00017-hard-currying-1/README.ja.md index c50cb4e2f..0ce15550d 100644 --- a/questions/17-hard-currying-1/README.ja.md +++ b/questions/00017-hard-currying-1/README.ja.md @@ -18,4 +18,4 @@ const five = curriedAdd(2)(3) この課題では、カリー化された関数は一度に 1 つの引数しか受け付けません。すべての引数が代入されたら、その結果を返す必要があります。 -
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 16・Pop 462・Currying 2 \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

14・First of Array 16・Pop 462・Currying 2 \ No newline at end of file diff --git a/questions/17-hard-currying-1/README.md b/questions/00017-hard-currying-1/README.md similarity index 75% rename from questions/17-hard-currying-1/README.md rename to questions/00017-hard-currying-1/README.md index 6d70dce06..8a6286fd7 100644 --- a/questions/17-hard-currying-1/README.md +++ b/questions/00017-hard-currying-1/README.md @@ -18,4 +18,4 @@ The function passed to `Currying` may have multiple arguments, you need to corre In this challenge, the curried function only accept one argument at a time. Once all the argument is assigned, it should return its result. -
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 16・Pop 462・Currying 2 +
Back Share your Solutions Check out Solutions

Related Challenges

14・First of Array 16・Pop 462・Currying 2 diff --git a/questions/17-hard-currying-1/README.zh-CN.md b/questions/00017-hard-currying-1/README.zh-CN.md similarity index 73% rename from questions/17-hard-currying-1/README.zh-CN.md rename to questions/00017-hard-currying-1/README.zh-CN.md index 43d8ce2d1..ad48f4b95 100644 --- a/questions/17-hard-currying-1/README.zh-CN.md +++ b/questions/00017-hard-currying-1/README.zh-CN.md @@ -20,4 +20,4 @@ const five = curriedAdd(2)(3) 在此挑战中,curried函数一次仅接受一个参数。分配完所有参数后,它应返回其结果。 -
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 16・出堆 462・柯里化 2 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 16・出堆 462・柯里化 2 \ No newline at end of file diff --git a/questions/17-hard-currying-1/info.yml b/questions/00017-hard-currying-1/info.yml similarity index 100% rename from questions/17-hard-currying-1/info.yml rename to questions/00017-hard-currying-1/info.yml diff --git a/questions/17-hard-currying-1/info.zh-CN.yml b/questions/00017-hard-currying-1/info.zh-CN.yml similarity index 100% rename from questions/17-hard-currying-1/info.zh-CN.yml rename to questions/00017-hard-currying-1/info.zh-CN.yml diff --git a/questions/17-hard-currying-1/template.ts b/questions/00017-hard-currying-1/template.ts similarity index 100% rename from questions/17-hard-currying-1/template.ts rename to questions/00017-hard-currying-1/template.ts diff --git a/questions/17-hard-currying-1/test-cases.ts b/questions/00017-hard-currying-1/test-cases.ts similarity index 100% rename from questions/17-hard-currying-1/test-cases.ts rename to questions/00017-hard-currying-1/test-cases.ts diff --git a/questions/18-easy-tuple-length/README.ja.md b/questions/00018-easy-tuple-length/README.ja.md similarity index 100% rename from questions/18-easy-tuple-length/README.ja.md rename to questions/00018-easy-tuple-length/README.ja.md diff --git a/questions/18-easy-tuple-length/README.ko.md b/questions/00018-easy-tuple-length/README.ko.md similarity index 100% rename from questions/18-easy-tuple-length/README.ko.md rename to questions/00018-easy-tuple-length/README.ko.md diff --git a/questions/18-easy-tuple-length/README.md b/questions/00018-easy-tuple-length/README.md similarity index 100% rename from questions/18-easy-tuple-length/README.md rename to questions/00018-easy-tuple-length/README.md diff --git a/questions/18-easy-tuple-length/README.zh-CN.md b/questions/00018-easy-tuple-length/README.zh-CN.md similarity index 100% rename from questions/18-easy-tuple-length/README.zh-CN.md rename to questions/00018-easy-tuple-length/README.zh-CN.md diff --git a/questions/18-easy-tuple-length/info.yml b/questions/00018-easy-tuple-length/info.yml similarity index 100% rename from questions/18-easy-tuple-length/info.yml rename to questions/00018-easy-tuple-length/info.yml diff --git a/questions/18-easy-tuple-length/info.zh-CN.yml b/questions/00018-easy-tuple-length/info.zh-CN.yml similarity index 100% rename from questions/18-easy-tuple-length/info.zh-CN.yml rename to questions/00018-easy-tuple-length/info.zh-CN.yml diff --git a/questions/18-easy-tuple-length/template.ts b/questions/00018-easy-tuple-length/template.ts similarity index 100% rename from questions/18-easy-tuple-length/template.ts rename to questions/00018-easy-tuple-length/template.ts diff --git a/questions/18-easy-tuple-length/test-cases.ts b/questions/00018-easy-tuple-length/test-cases.ts similarity index 100% rename from questions/18-easy-tuple-length/test-cases.ts rename to questions/00018-easy-tuple-length/test-cases.ts diff --git a/questions/20-medium-promise-all/README.ja.md b/questions/00020-medium-promise-all/README.ja.md similarity index 100% rename from questions/20-medium-promise-all/README.ja.md rename to questions/00020-medium-promise-all/README.ja.md diff --git a/questions/20-medium-promise-all/README.md b/questions/00020-medium-promise-all/README.md similarity index 99% rename from questions/20-medium-promise-all/README.md rename to questions/00020-medium-promise-all/README.md index 019d549d6..97ac79ac2 100644 --- a/questions/20-medium-promise-all/README.md +++ b/questions/00020-medium-promise-all/README.md @@ -1,17 +1,17 @@ -

Promise.all medium #array #built-in

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Type the function `PromiseAll` that accepts an array of PromiseLike objects, the returning value should be `Promise` where `T` is the resolved result array. - -```ts -const promise1 = Promise.resolve(3); -const promise2 = 42; -const promise3 = new Promise((resolve, reject) => { - setTimeout(resolve, 100, 'foo'); -}); - -// expected to be `Promise<[number, 42, string]>` -const p = Promise.all([promise1, promise2, promise3] as const) -``` - - -
Back Share your Solutions Check out Solutions +

Promise.all medium #array #built-in

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Type the function `PromiseAll` that accepts an array of PromiseLike objects, the returning value should be `Promise` where `T` is the resolved result array. + +```ts +const promise1 = Promise.resolve(3); +const promise2 = 42; +const promise3 = new Promise((resolve, reject) => { + setTimeout(resolve, 100, 'foo'); +}); + +// expected to be `Promise<[number, 42, string]>` +const p = Promise.all([promise1, promise2, promise3] as const) +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/20-medium-promise-all/README.zh-CN.md b/questions/00020-medium-promise-all/README.zh-CN.md similarity index 99% rename from questions/20-medium-promise-all/README.zh-CN.md rename to questions/00020-medium-promise-all/README.zh-CN.md index cd530bfd4..db6698604 100644 --- a/questions/20-medium-promise-all/README.zh-CN.md +++ b/questions/00020-medium-promise-all/README.zh-CN.md @@ -1,18 +1,18 @@ -

Promise.all 中等 #array #built-in

by Anthony Fu @antfu

接受挑战    English 日本語

- -> 由谷歌自动翻译,欢迎 PR 改进翻译质量。 - -键入函数`PromiseAll`,它接受PromiseLike对象数组,返回值应为`Promise`,其中`T`是解析的结果数组。 - -```ts -const promise1 = Promise.resolve(3); -const promise2 = 42; -const promise3 = new Promise((resolve, reject) => { - setTimeout(resolve, 100, 'foo'); -}); - -// expected to be `Promise<[number, 42, string]>` -const p = Promise.all([promise1, promise2, promise3] as const) -``` - -
返回首页 分享你的解答 查看解答 +

Promise.all 中等 #array #built-in

by Anthony Fu @antfu

接受挑战    English 日本語

+ +> 由谷歌自动翻译,欢迎 PR 改进翻译质量。 + +键入函数`PromiseAll`,它接受PromiseLike对象数组,返回值应为`Promise`,其中`T`是解析的结果数组。 + +```ts +const promise1 = Promise.resolve(3); +const promise2 = 42; +const promise3 = new Promise((resolve, reject) => { + setTimeout(resolve, 100, 'foo'); +}); + +// expected to be `Promise<[number, 42, string]>` +const p = Promise.all([promise1, promise2, promise3] as const) +``` + +
返回首页 分享你的解答 查看解答 diff --git a/questions/20-medium-promise-all/info.yml b/questions/00020-medium-promise-all/info.yml similarity index 100% rename from questions/20-medium-promise-all/info.yml rename to questions/00020-medium-promise-all/info.yml diff --git a/questions/20-medium-promise-all/template.ts b/questions/00020-medium-promise-all/template.ts similarity index 100% rename from questions/20-medium-promise-all/template.ts rename to questions/00020-medium-promise-all/template.ts diff --git a/questions/20-medium-promise-all/test-cases.ts b/questions/00020-medium-promise-all/test-cases.ts similarity index 97% rename from questions/20-medium-promise-all/test-cases.ts rename to questions/00020-medium-promise-all/test-cases.ts index d8115ce6d..85d330b46 100644 --- a/questions/20-medium-promise-all/test-cases.ts +++ b/questions/00020-medium-promise-all/test-cases.ts @@ -1,11 +1,11 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -const promiseAllTest1 = PromiseAll([1, 2, 3] as const) -const promiseAllTest2 = PromiseAll([1, 2, Promise.resolve(3)] as const) -const promiseAllTest3 = PromiseAll([1, 2, Promise.resolve(3)]) - -type cases = [ - Expect>>, - Expect>>, - Expect>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +const promiseAllTest1 = PromiseAll([1, 2, 3] as const) +const promiseAllTest2 = PromiseAll([1, 2, Promise.resolve(3)] as const) +const promiseAllTest3 = PromiseAll([1, 2, Promise.resolve(3)]) + +type cases = [ + Expect>>, + Expect>>, + Expect>>, +] diff --git a/questions/43-easy-exclude/README.ja.md b/questions/00043-easy-exclude/README.ja.md similarity index 100% rename from questions/43-easy-exclude/README.ja.md rename to questions/00043-easy-exclude/README.ja.md diff --git a/questions/43-easy-exclude/README.ko.md b/questions/00043-easy-exclude/README.ko.md similarity index 100% rename from questions/43-easy-exclude/README.ko.md rename to questions/00043-easy-exclude/README.ko.md diff --git a/questions/43-easy-exclude/README.md b/questions/00043-easy-exclude/README.md similarity index 99% rename from questions/43-easy-exclude/README.md rename to questions/00043-easy-exclude/README.md index af04ecf8a..fcc78cf0c 100644 --- a/questions/43-easy-exclude/README.md +++ b/questions/00043-easy-exclude/README.md @@ -1,6 +1,6 @@

Exclude easy #built-in

by Zheeeng @zheeeng

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

-Implement the built-in Exclude +Implement the built-in Exclude > Exclude from T those types that are assignable to U diff --git a/questions/43-easy-exclude/README.zh-CN.md b/questions/00043-easy-exclude/README.zh-CN.md similarity index 99% rename from questions/43-easy-exclude/README.zh-CN.md rename to questions/00043-easy-exclude/README.zh-CN.md index 2a14f03be..7dd63aa83 100644 --- a/questions/43-easy-exclude/README.zh-CN.md +++ b/questions/00043-easy-exclude/README.zh-CN.md @@ -1,8 +1,8 @@ -

Exclude 简单 #built-in

by Zheeeng @zheeeng

接受挑战    English 日本語 한국어

- -> 欢迎 PR 改进翻译质量。 - -实现内置的Exclude 类型,但不能直接使用它本身。 ->从联合类型T中排除U的类型成员,来构造一个新的类型。 - +

Exclude 简单 #built-in

by Zheeeng @zheeeng

接受挑战    English 日本語 한국어

+ +> 欢迎 PR 改进翻译质量。 + +实现内置的Exclude 类型,但不能直接使用它本身。 +>从联合类型T中排除U的类型成员,来构造一个新的类型。 +
返回首页 分享你的解答 查看解答 \ No newline at end of file diff --git a/questions/43-easy-exclude/info.yml b/questions/00043-easy-exclude/info.yml similarity index 100% rename from questions/43-easy-exclude/info.yml rename to questions/00043-easy-exclude/info.yml diff --git a/questions/43-easy-exclude/template.ts b/questions/00043-easy-exclude/template.ts similarity index 100% rename from questions/43-easy-exclude/template.ts rename to questions/00043-easy-exclude/template.ts diff --git a/questions/43-easy-exclude/test-cases.ts b/questions/00043-easy-exclude/test-cases.ts similarity index 98% rename from questions/43-easy-exclude/test-cases.ts rename to questions/00043-easy-exclude/test-cases.ts index 7e2dad8e9..c9666766b 100644 --- a/questions/43-easy-exclude/test-cases.ts +++ b/questions/00043-easy-exclude/test-cases.ts @@ -1,7 +1,7 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, Exclude<'a' | 'b' | 'c', 'a'>>>, - Expect, Exclude<'a' | 'b' | 'c', 'a' | 'b'>>>, - Expect void), Function>, Exclude void), Function>>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, Exclude<'a' | 'b' | 'c', 'a'>>>, + Expect, Exclude<'a' | 'b' | 'c', 'a' | 'b'>>>, + Expect void), Function>, Exclude void), Function>>>, +] diff --git a/questions/55-hard-union-to-intersection/README.ja.md b/questions/00055-hard-union-to-intersection/README.ja.md similarity index 100% rename from questions/55-hard-union-to-intersection/README.ja.md rename to questions/00055-hard-union-to-intersection/README.ja.md diff --git a/questions/55-hard-union-to-intersection/README.md b/questions/00055-hard-union-to-intersection/README.md similarity index 99% rename from questions/55-hard-union-to-intersection/README.md rename to questions/00055-hard-union-to-intersection/README.md index aa7d4ca66..3ebdb4cb0 100644 --- a/questions/55-hard-union-to-intersection/README.md +++ b/questions/00055-hard-union-to-intersection/README.md @@ -1,11 +1,11 @@

Union to Intersection hard #utils #infer

by Zheeeng @zheeeng

Take the Challenge    简体中文 日本語

-Implement the advanced util type `UnionToIntersection` - -For example - -```ts -type I = Union2Intersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true +Implement the advanced util type `UnionToIntersection` + +For example + +```ts +type I = Union2Intersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true ``` diff --git a/questions/55-hard-union-to-intersection/README.zh-CN.md b/questions/00055-hard-union-to-intersection/README.zh-CN.md similarity index 99% rename from questions/55-hard-union-to-intersection/README.zh-CN.md rename to questions/00055-hard-union-to-intersection/README.zh-CN.md index 7baa1094f..1994526db 100644 --- a/questions/55-hard-union-to-intersection/README.zh-CN.md +++ b/questions/00055-hard-union-to-intersection/README.zh-CN.md @@ -2,12 +2,12 @@ > 由谷歌自动翻译,欢迎 PR 改进翻译质量。 -实现高级util类型`UnionToIntersection` - -例如 - -```ts -type I = Union2Intersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true +实现高级util类型`UnionToIntersection` + +例如 + +```ts +type I = Union2Intersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true ```
返回首页 分享你的解答 查看解答 \ No newline at end of file diff --git a/questions/55-hard-union-to-intersection/info.yml b/questions/00055-hard-union-to-intersection/info.yml similarity index 100% rename from questions/55-hard-union-to-intersection/info.yml rename to questions/00055-hard-union-to-intersection/info.yml diff --git a/questions/55-hard-union-to-intersection/template.ts b/questions/00055-hard-union-to-intersection/template.ts similarity index 100% rename from questions/55-hard-union-to-intersection/template.ts rename to questions/00055-hard-union-to-intersection/template.ts diff --git a/questions/55-hard-union-to-intersection/test-cases.ts b/questions/00055-hard-union-to-intersection/test-cases.ts similarity index 97% rename from questions/55-hard-union-to-intersection/test-cases.ts rename to questions/00055-hard-union-to-intersection/test-cases.ts index d8c68c45f..99963227e 100644 --- a/questions/55-hard-union-to-intersection/test-cases.ts +++ b/questions/00055-hard-union-to-intersection/test-cases.ts @@ -1,6 +1,6 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'foo' & 42 & true>>, - Expect 'foo') | ((i: 42) => true)>, (() => 'foo') & ((i: 42) => true)>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'foo' & 42 & true>>, + Expect 'foo') | ((i: 42) => true)>, (() => 'foo') & ((i: 42) => true)>>, +] diff --git a/questions/57-hard-get-required/README.ja.md b/questions/00057-hard-get-required/README.ja.md similarity index 89% rename from questions/57-hard-get-required/README.ja.md rename to questions/00057-hard-get-required/README.ja.md index 90966f890..cc057b295 100644 --- a/questions/57-hard-get-required/README.ja.md +++ b/questions/00057-hard-get-required/README.ja.md @@ -8,4 +8,4 @@ type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number } ``` -
戻る 解答を共有 解答を確認

関連する課題

59・Get Optional \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

59・Get Optional \ No newline at end of file diff --git a/questions/57-hard-get-required/README.md b/questions/00057-hard-get-required/README.md similarity index 88% rename from questions/57-hard-get-required/README.md rename to questions/00057-hard-get-required/README.md index 88c177df1..42b81abb4 100644 --- a/questions/57-hard-get-required/README.md +++ b/questions/00057-hard-get-required/README.md @@ -1,12 +1,12 @@

Get Required hard #utils #infer

by Zheeeng @zheeeng

Take the Challenge    简体中文 日本語

-Implement the advanced util type `GetRequired`, which remains all the required fields - -For example - -```ts -type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number } +Implement the advanced util type `GetRequired`, which remains all the required fields + +For example + +```ts +type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number } ``` -
Back Share your Solutions Check out Solutions

Related Challenges

59・Get Optional \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

59・Get Optional \ No newline at end of file diff --git a/questions/57-hard-get-required/README.zh-CN.md b/questions/00057-hard-get-required/README.zh-CN.md similarity index 88% rename from questions/57-hard-get-required/README.zh-CN.md rename to questions/00057-hard-get-required/README.zh-CN.md index 01179e2a2..fe04d6403 100644 --- a/questions/57-hard-get-required/README.zh-CN.md +++ b/questions/00057-hard-get-required/README.zh-CN.md @@ -2,12 +2,12 @@ > 由谷歌自动翻译,欢迎 PR 改进翻译质量。 -实现高级util类型`GetRequired`,该类型保留所有必填字段 - -例如 - -```ts -type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number } +实现高级util类型`GetRequired`,该类型保留所有必填字段 + +例如 + +```ts +type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number } ``` -
返回首页 分享你的解答 查看解答

相关挑战

59・Get Optional \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

59・Get Optional \ No newline at end of file diff --git a/questions/57-hard-get-required/info.yml b/questions/00057-hard-get-required/info.yml similarity index 100% rename from questions/57-hard-get-required/info.yml rename to questions/00057-hard-get-required/info.yml diff --git a/questions/57-hard-get-required/template.ts b/questions/00057-hard-get-required/template.ts similarity index 100% rename from questions/57-hard-get-required/template.ts rename to questions/00057-hard-get-required/template.ts diff --git a/questions/57-hard-get-required/test-cases.ts b/questions/00057-hard-get-required/test-cases.ts similarity index 97% rename from questions/57-hard-get-required/test-cases.ts rename to questions/00057-hard-get-required/test-cases.ts index 0bd2706c6..8ca8138fc 100644 --- a/questions/57-hard-get-required/test-cases.ts +++ b/questions/00057-hard-get-required/test-cases.ts @@ -1,6 +1,6 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, { foo: number }>>, - Expect, { foo: undefined }>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, { foo: number }>>, + Expect, { foo: undefined }>>, +] diff --git a/questions/59-hard-get-optional/README.ja.md b/questions/00059-hard-get-optional/README.ja.md similarity index 89% rename from questions/59-hard-get-optional/README.ja.md rename to questions/00059-hard-get-optional/README.ja.md index 83af435cf..fcc5f2fd4 100644 --- a/questions/59-hard-get-optional/README.ja.md +++ b/questions/00059-hard-get-optional/README.ja.md @@ -8,4 +8,4 @@ type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } ``` -
戻る 解答を共有 解答を確認

関連する課題

57・Get Required \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

57・Get Required \ No newline at end of file diff --git a/questions/59-hard-get-optional/README.md b/questions/00059-hard-get-optional/README.md similarity index 88% rename from questions/59-hard-get-optional/README.md rename to questions/00059-hard-get-optional/README.md index 7ba52136c..f85e15d5b 100644 --- a/questions/59-hard-get-optional/README.md +++ b/questions/00059-hard-get-optional/README.md @@ -1,12 +1,12 @@

Get Optional hard #utils #infer

by Zheeeng @zheeeng

Take the Challenge    简体中文 日本語

-Implement the advanced util type `GetOptional`, which remains all the optional fields - -For example - -```ts -type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } +Implement the advanced util type `GetOptional`, which remains all the optional fields + +For example + +```ts +type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } ``` -
Back Share your Solutions Check out Solutions

Related Challenges

57・Get Required \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

57・Get Required \ No newline at end of file diff --git a/questions/59-hard-get-optional/README.zh-CN.md b/questions/00059-hard-get-optional/README.zh-CN.md similarity index 88% rename from questions/59-hard-get-optional/README.zh-CN.md rename to questions/00059-hard-get-optional/README.zh-CN.md index fb114e050..6af7301da 100644 --- a/questions/59-hard-get-optional/README.zh-CN.md +++ b/questions/00059-hard-get-optional/README.zh-CN.md @@ -2,12 +2,12 @@ > 由谷歌自动翻译,欢迎 PR 改进翻译质量。 -实现高级util类型`GetOptional`,该类型保留所有可选字段 - -例如 - -```ts -type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } +实现高级util类型`GetOptional`,该类型保留所有可选字段 + +例如 + +```ts +type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } ``` -
返回首页 分享你的解答 查看解答

相关挑战

57・Get Required \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

57・Get Required \ No newline at end of file diff --git a/questions/59-hard-get-optional/info.yml b/questions/00059-hard-get-optional/info.yml similarity index 100% rename from questions/59-hard-get-optional/info.yml rename to questions/00059-hard-get-optional/info.yml diff --git a/questions/59-hard-get-optional/template.ts b/questions/00059-hard-get-optional/template.ts similarity index 100% rename from questions/59-hard-get-optional/template.ts rename to questions/00059-hard-get-optional/template.ts diff --git a/questions/59-hard-get-optional/test-cases.ts b/questions/00059-hard-get-optional/test-cases.ts similarity index 98% rename from questions/59-hard-get-optional/test-cases.ts rename to questions/00059-hard-get-optional/test-cases.ts index 12d795aee..db8b6efcc 100644 --- a/questions/59-hard-get-optional/test-cases.ts +++ b/questions/00059-hard-get-optional/test-cases.ts @@ -1,6 +1,6 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, { bar?: string }>>, - Expect, { bar?: undefined }>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, { bar?: string }>>, + Expect, { bar?: undefined }>>, ] diff --git a/questions/62-medium-type-lookup/README.ja.md b/questions/00062-medium-type-lookup/README.ja.md similarity index 100% rename from questions/62-medium-type-lookup/README.ja.md rename to questions/00062-medium-type-lookup/README.ja.md diff --git a/questions/62-medium-type-lookup/README.md b/questions/00062-medium-type-lookup/README.md similarity index 98% rename from questions/62-medium-type-lookup/README.md rename to questions/00062-medium-type-lookup/README.md index dd92fb267..389d6829d 100644 --- a/questions/62-medium-type-lookup/README.md +++ b/questions/00062-medium-type-lookup/README.md @@ -1,23 +1,23 @@ -

Type Lookup medium #union #map

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Sometimes, you may want to lookup for a type in a union to by their attributes. - -In this challenge, we would like to get the corresponding type by searching for the common `type` field in the union `Cat | Dog`. In other words, we will expect to get `Dog` for `LookUp` and `Cat` for `LookUp` in the following example. - -```ts -interface Cat { - type: 'cat' - breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' -} - -interface Dog { - type: 'dog' - breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' - color: 'brown' | 'white' | 'black' -} - -type MyDogType = LookUp // expected to be `Dog` -``` - - -
Back Share your Solutions Check out Solutions +

Type Lookup medium #union #map

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Sometimes, you may want to lookup for a type in a union to by their attributes. + +In this challenge, we would like to get the corresponding type by searching for the common `type` field in the union `Cat | Dog`. In other words, we will expect to get `Dog` for `LookUp` and `Cat` for `LookUp` in the following example. + +```ts +interface Cat { + type: 'cat' + breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' +} + +interface Dog { + type: 'dog' + breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' + color: 'brown' | 'white' | 'black' +} + +type MyDogType = LookUp // expected to be `Dog` +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/62-medium-type-lookup/README.zh-CN.md b/questions/00062-medium-type-lookup/README.zh-CN.md similarity index 98% rename from questions/62-medium-type-lookup/README.zh-CN.md rename to questions/00062-medium-type-lookup/README.zh-CN.md index a55645b5e..a4b93fdb0 100644 --- a/questions/62-medium-type-lookup/README.zh-CN.md +++ b/questions/00062-medium-type-lookup/README.zh-CN.md @@ -1,24 +1,24 @@ -

Type Lookup 中等 #union #map

by Anthony Fu @antfu

接受挑战    English 日本語

- -> 由谷歌自动翻译,欢迎 PR 改进翻译质量。 - -有时,您可能希望根据其属性在并集中查找类型。 - -在此挑战中,我们想通过在联合`Cat | Dog`中搜索公共`type`字段来获取相应的类型。换句话说,在以下示例中,我们期望`LookUp`获得`Dog`,`LookUp`获得`Cat`。 - -```ts -interface Cat { - type: 'cat' - breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' -} - -interface Dog { - type: 'dog' - breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' - color: 'brown' | 'white' | 'black' -} - -type MyDog = LookUp // expected to be `Dog` -``` - +

Type Lookup 中等 #union #map

by Anthony Fu @antfu

接受挑战    English 日本語

+ +> 由谷歌自动翻译,欢迎 PR 改进翻译质量。 + +有时,您可能希望根据其属性在并集中查找类型。 + +在此挑战中,我们想通过在联合`Cat | Dog`中搜索公共`type`字段来获取相应的类型。换句话说,在以下示例中,我们期望`LookUp`获得`Dog`,`LookUp`获得`Cat`。 + +```ts +interface Cat { + type: 'cat' + breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' +} + +interface Dog { + type: 'dog' + breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' + color: 'brown' | 'white' | 'black' +} + +type MyDog = LookUp // expected to be `Dog` +``` +
返回首页 分享你的解答 查看解答 \ No newline at end of file diff --git a/questions/62-medium-type-lookup/info.yml b/questions/00062-medium-type-lookup/info.yml similarity index 100% rename from questions/62-medium-type-lookup/info.yml rename to questions/00062-medium-type-lookup/info.yml diff --git a/questions/62-medium-type-lookup/template.ts b/questions/00062-medium-type-lookup/template.ts similarity index 100% rename from questions/62-medium-type-lookup/template.ts rename to questions/00062-medium-type-lookup/template.ts diff --git a/questions/62-medium-type-lookup/test-cases.ts b/questions/00062-medium-type-lookup/test-cases.ts similarity index 95% rename from questions/62-medium-type-lookup/test-cases.ts rename to questions/00062-medium-type-lookup/test-cases.ts index bde22fec7..441abcff1 100644 --- a/questions/62-medium-type-lookup/test-cases.ts +++ b/questions/00062-medium-type-lookup/test-cases.ts @@ -1,19 +1,19 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -interface Cat { - type: 'cat' - breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' -} - -interface Dog { - type: 'dog' - breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' - color: 'brown' | 'white' | 'black' -} - -type Animal = Cat | Dog - -type cases = [ - Expect, Dog>>, - Expect, Cat>>, +import type { Equal, Expect } from '@type-challenges/utils' + +interface Cat { + type: 'cat' + breeds: 'Abyssinian' | 'Shorthair' | 'Curl' | 'Bengal' +} + +interface Dog { + type: 'dog' + breeds: 'Hound' | 'Brittany' | 'Bulldog' | 'Boxer' + color: 'brown' | 'white' | 'black' +} + +type Animal = Cat | Dog + +type cases = [ + Expect, Dog>>, + Expect, Cat>>, ] diff --git a/questions/89-hard-required-keys/README.ja.md b/questions/00089-hard-required-keys/README.ja.md similarity index 88% rename from questions/89-hard-required-keys/README.ja.md rename to questions/00089-hard-required-keys/README.ja.md index 243fa9d94..84b06ce22 100644 --- a/questions/89-hard-required-keys/README.ja.md +++ b/questions/00089-hard-required-keys/README.ja.md @@ -9,4 +9,4 @@ type Result = RequiredKeys<{ foo: number; bar?: string }>; // expected to be “foo” ``` -
戻る 解答を共有 解答を確認

関連する課題

5・Get Readonly Keys \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

5・Get Readonly Keys \ No newline at end of file diff --git a/questions/89-hard-required-keys/README.md b/questions/00089-hard-required-keys/README.md similarity index 87% rename from questions/89-hard-required-keys/README.md rename to questions/00089-hard-required-keys/README.md index 9547d8d1d..587181e72 100644 --- a/questions/89-hard-required-keys/README.md +++ b/questions/00089-hard-required-keys/README.md @@ -1,13 +1,13 @@

Required Keys hard #utils

by yituan @yi-tuan

Take the Challenge    简体中文 日本語

-Implement the advanced util type `RequiredKeys`, which picks all the required keys into a union. - -For example - -```ts -type Result = RequiredKeys<{ foo: number; bar?: string }>; -// expected to be “foo” +Implement the advanced util type `RequiredKeys`, which picks all the required keys into a union. + +For example + +```ts +type Result = RequiredKeys<{ foo: number; bar?: string }>; +// expected to be “foo” ``` -
Back Share your Solutions Check out Solutions

Related Challenges

5・Get Readonly Keys \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

5・Get Readonly Keys \ No newline at end of file diff --git a/questions/89-hard-required-keys/README.zh-CN.md b/questions/00089-hard-required-keys/README.zh-CN.md similarity index 85% rename from questions/89-hard-required-keys/README.zh-CN.md rename to questions/00089-hard-required-keys/README.zh-CN.md index e65191fde..74e0e7bad 100644 --- a/questions/89-hard-required-keys/README.zh-CN.md +++ b/questions/00089-hard-required-keys/README.zh-CN.md @@ -2,13 +2,13 @@ > 由谷歌自动翻译,欢迎 PR 改进翻译质量。 -实现高级util类型`RequiredKeys`,该类型将所有必需的键都选择为一个并集。 - -例如 - -```ts -type Result = RequiredKeys<{ foo: number; bar?: string }>; -// expected to be “foo” +实现高级util类型`RequiredKeys`,该类型将所有必需的键都选择为一个并集。 + +例如 + +```ts +type Result = RequiredKeys<{ foo: number; bar?: string }>; +// expected to be “foo” ``` -
返回首页 分享你的解答 查看解答

相关挑战

5・获取只读字段 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

5・获取只读字段 \ No newline at end of file diff --git a/questions/89-hard-required-keys/info.yml b/questions/00089-hard-required-keys/info.yml similarity index 100% rename from questions/89-hard-required-keys/info.yml rename to questions/00089-hard-required-keys/info.yml diff --git a/questions/89-hard-required-keys/template.ts b/questions/00089-hard-required-keys/template.ts similarity index 100% rename from questions/89-hard-required-keys/template.ts rename to questions/00089-hard-required-keys/template.ts diff --git a/questions/89-hard-required-keys/test-cases.ts b/questions/00089-hard-required-keys/test-cases.ts similarity index 98% rename from questions/89-hard-required-keys/test-cases.ts rename to questions/00089-hard-required-keys/test-cases.ts index b264b5d6c..ad9248db7 100644 --- a/questions/89-hard-required-keys/test-cases.ts +++ b/questions/00089-hard-required-keys/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'a'>>, - Expect, 'a'>>, - Expect, 'a' | 'c' | 'd'>>, - Expect, never>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'a'>>, + Expect, 'a'>>, + Expect, 'a' | 'c' | 'd'>>, + Expect, never>>, ] diff --git a/questions/90-hard-optional-keys/README.ja.md b/questions/00090-hard-optional-keys/README.ja.md similarity index 77% rename from questions/90-hard-optional-keys/README.ja.md rename to questions/00090-hard-optional-keys/README.ja.md index 7776caeb3..56e2181da 100644 --- a/questions/90-hard-optional-keys/README.ja.md +++ b/questions/00090-hard-optional-keys/README.ja.md @@ -2,4 +2,4 @@ オプショナルなキーの Union を抽出する高度なユーティリティ型 `OptionalKeys` を実装してください。 -
戻る 解答を共有 解答を確認

関連する課題

89・Required Keys 5・Get Readonly Keys \ No newline at end of file +
戻る 解答を共有 解答を確認

関連する課題

89・Required Keys 5・Get Readonly Keys \ No newline at end of file diff --git a/questions/90-hard-optional-keys/README.md b/questions/00090-hard-optional-keys/README.md similarity index 76% rename from questions/90-hard-optional-keys/README.md rename to questions/00090-hard-optional-keys/README.md index 47129d9cf..554ba52bb 100644 --- a/questions/90-hard-optional-keys/README.md +++ b/questions/00090-hard-optional-keys/README.md @@ -3,4 +3,4 @@ Implement the advanced util type `OptionalKeys`, which picks all the optional keys into a union. -
Back Share your Solutions Check out Solutions

Related Challenges

89・Required Keys 5・Get Readonly Keys \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

89・Required Keys 5・Get Readonly Keys \ No newline at end of file diff --git a/questions/90-hard-optional-keys/README.zh-CN.md b/questions/00090-hard-optional-keys/README.zh-CN.md similarity index 75% rename from questions/90-hard-optional-keys/README.zh-CN.md rename to questions/00090-hard-optional-keys/README.zh-CN.md index 5f5cdba33..2338b01e2 100644 --- a/questions/90-hard-optional-keys/README.zh-CN.md +++ b/questions/00090-hard-optional-keys/README.zh-CN.md @@ -4,4 +4,4 @@ 实现高级util类型`OptionalKeys`,该类型将所有可选键合并为一个并集。 -
返回首页 分享你的解答 查看解答

相关挑战

89・Required Keys 5・获取只读字段 \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

89・Required Keys 5・获取只读字段 \ No newline at end of file diff --git a/questions/90-hard-optional-keys/info.yml b/questions/00090-hard-optional-keys/info.yml similarity index 100% rename from questions/90-hard-optional-keys/info.yml rename to questions/00090-hard-optional-keys/info.yml diff --git a/questions/90-hard-optional-keys/template.ts b/questions/00090-hard-optional-keys/template.ts similarity index 100% rename from questions/90-hard-optional-keys/template.ts rename to questions/00090-hard-optional-keys/template.ts diff --git a/questions/90-hard-optional-keys/test-cases.ts b/questions/00090-hard-optional-keys/test-cases.ts similarity index 98% rename from questions/90-hard-optional-keys/test-cases.ts rename to questions/00090-hard-optional-keys/test-cases.ts index ba3aaca44..d021cd9a0 100644 --- a/questions/90-hard-optional-keys/test-cases.ts +++ b/questions/00090-hard-optional-keys/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'b'>>, - Expect, 'b'>>, - Expect, 'b' | 'c' | 'd'>>, - Expect, never>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'b'>>, + Expect, 'b'>>, + Expect, 'b' | 'c' | 'd'>>, + Expect, never>>, ] diff --git a/questions/106-medium-trimleft/README.ja.md b/questions/00106-medium-trimleft/README.ja.md similarity index 80% rename from questions/106-medium-trimleft/README.ja.md rename to questions/00106-medium-trimleft/README.ja.md index de38e4578..125b069c0 100644 --- a/questions/106-medium-trimleft/README.ja.md +++ b/questions/00106-medium-trimleft/README.ja.md @@ -9,4 +9,4 @@ type trimed = TrimLeft<' Hello World '> // expected to be 'Hello World ' ``` -
戻る 解答を共有 解答を確認

関連する課題

108・Trim 4803・Trim Right +
戻る 解答を共有 解答を確認

関連する課題

108・Trim 4803・Trim Right diff --git a/questions/106-medium-trimleft/README.md b/questions/00106-medium-trimleft/README.md similarity index 78% rename from questions/106-medium-trimleft/README.md rename to questions/00106-medium-trimleft/README.md index 5d74ece36..4be41dd41 100644 --- a/questions/106-medium-trimleft/README.md +++ b/questions/00106-medium-trimleft/README.md @@ -1,12 +1,12 @@ -

Trim Left medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Implement `TrimLeft` which takes an exact string type and returns a new string with the whitespace beginning removed. - -For example - -```ts -type trimed = TrimLeft<' Hello World '> // expected to be 'Hello World ' -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

108・Trim 4803・Trim Right +

Trim Left medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Implement `TrimLeft` which takes an exact string type and returns a new string with the whitespace beginning removed. + +For example + +```ts +type trimed = TrimLeft<' Hello World '> // expected to be 'Hello World ' +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

108・Trim 4803・Trim Right diff --git a/questions/106-medium-trimleft/README.zh-CN.md b/questions/00106-medium-trimleft/README.zh-CN.md similarity index 79% rename from questions/106-medium-trimleft/README.zh-CN.md rename to questions/00106-medium-trimleft/README.zh-CN.md index c8fe2aa8e..7d1224380 100644 --- a/questions/106-medium-trimleft/README.zh-CN.md +++ b/questions/00106-medium-trimleft/README.zh-CN.md @@ -8,4 +8,4 @@ type trimed = TrimLeft<' Hello World '> // 应推导出 'Hello World ' ``` -
返回首页 分享你的解答 查看解答

相关挑战

108・Trim 4803・Trim Right +
返回首页 分享你的解答 查看解答

相关挑战

108・Trim 4803・Trim Right diff --git a/questions/106-medium-trimleft/info.yml b/questions/00106-medium-trimleft/info.yml similarity index 100% rename from questions/106-medium-trimleft/info.yml rename to questions/00106-medium-trimleft/info.yml diff --git a/questions/106-medium-trimleft/template.ts b/questions/00106-medium-trimleft/template.ts similarity index 100% rename from questions/106-medium-trimleft/template.ts rename to questions/00106-medium-trimleft/template.ts diff --git a/questions/106-medium-trimleft/test-cases.ts b/questions/00106-medium-trimleft/test-cases.ts similarity index 97% rename from questions/106-medium-trimleft/test-cases.ts rename to questions/00106-medium-trimleft/test-cases.ts index 6eb20089d..a1b4b9296 100644 --- a/questions/106-medium-trimleft/test-cases.ts +++ b/questions/00106-medium-trimleft/test-cases.ts @@ -1,11 +1,11 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str '>>, - Expect, 'foo bar '>>, - Expect, ''>>, - Expect, ''>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str '>>, + Expect, 'foo bar '>>, + Expect, ''>>, + Expect, ''>>, +] diff --git a/questions/108-medium-trim/README.ja.md b/questions/00108-medium-trim/README.ja.md similarity index 79% rename from questions/108-medium-trim/README.ja.md rename to questions/00108-medium-trim/README.ja.md index 084c2266f..2418106fb 100644 --- a/questions/108-medium-trim/README.ja.md +++ b/questions/00108-medium-trim/README.ja.md @@ -9,4 +9,4 @@ type trimed = Trim<' Hello World '> // expected to be 'Hello World' ``` -
戻る 解答を共有 解答を確認

関連する課題

106・Trim Left 4803・Trim Right +
戻る 解答を共有 解答を確認

関連する課題

106・Trim Left 4803・Trim Right diff --git a/questions/108-medium-trim/README.md b/questions/00108-medium-trim/README.md similarity index 78% rename from questions/108-medium-trim/README.md rename to questions/00108-medium-trim/README.md index f00e89661..49e4b66d3 100644 --- a/questions/108-medium-trim/README.md +++ b/questions/00108-medium-trim/README.md @@ -1,12 +1,12 @@ -

Trim medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Implement `Trim` which takes an exact string type and returns a new string with the whitespace from both ends removed. - -For example - -```ts -type trimmed = Trim<' Hello World '> // expected to be 'Hello World' -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

106・Trim Left 4803・Trim Right +

Trim medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Implement `Trim` which takes an exact string type and returns a new string with the whitespace from both ends removed. + +For example + +```ts +type trimmed = Trim<' Hello World '> // expected to be 'Hello World' +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

106・Trim Left 4803・Trim Right diff --git a/questions/108-medium-trim/README.zh-CN.md b/questions/00108-medium-trim/README.zh-CN.md similarity index 77% rename from questions/108-medium-trim/README.zh-CN.md rename to questions/00108-medium-trim/README.zh-CN.md index 9c1b896a0..88c99e152 100644 --- a/questions/108-medium-trim/README.zh-CN.md +++ b/questions/00108-medium-trim/README.zh-CN.md @@ -9,5 +9,5 @@ type trimed = Trim<' Hello World '> // expected to be 'Hello World' ``` -
返回首页 分享你的解答 查看解答

相关挑战

106・Trim Left 4803・Trim Right +
返回首页 分享你的解答 查看解答

相关挑战

106・Trim Left 4803・Trim Right diff --git a/questions/108-medium-trim/info.yml b/questions/00108-medium-trim/info.yml similarity index 100% rename from questions/108-medium-trim/info.yml rename to questions/00108-medium-trim/info.yml diff --git a/questions/108-medium-trim/template.ts b/questions/00108-medium-trim/template.ts similarity index 100% rename from questions/108-medium-trim/template.ts rename to questions/00108-medium-trim/template.ts diff --git a/questions/108-medium-trim/test-cases.ts b/questions/00108-medium-trim/test-cases.ts similarity index 97% rename from questions/108-medium-trim/test-cases.ts rename to questions/00108-medium-trim/test-cases.ts index c13b03532..7e5f6afa3 100644 --- a/questions/108-medium-trim/test-cases.ts +++ b/questions/00108-medium-trim/test-cases.ts @@ -1,12 +1,12 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'foo bar'>>, - Expect, ''>>, - Expect, ''>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'foo bar'>>, + Expect, ''>>, + Expect, ''>>, +] diff --git a/questions/110-medium-capitalize/README.ja.md b/questions/00110-medium-capitalize/README.ja.md similarity index 100% rename from questions/110-medium-capitalize/README.ja.md rename to questions/00110-medium-capitalize/README.ja.md diff --git a/questions/110-medium-capitalize/README.md b/questions/00110-medium-capitalize/README.md similarity index 99% rename from questions/110-medium-capitalize/README.md rename to questions/00110-medium-capitalize/README.md index 34815887d..26644e34c 100644 --- a/questions/110-medium-capitalize/README.md +++ b/questions/00110-medium-capitalize/README.md @@ -1,12 +1,12 @@ -

Capitalize medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Implement `Capitalize` which converts the first letter of a string to uppercase and leave the rest as-is. - -For example - -```ts -type capitalized = Capitalize<'hello world'> // expected to be 'Hello world' -``` - - -
Back Share your Solutions Check out Solutions +

Capitalize medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Implement `Capitalize` which converts the first letter of a string to uppercase and leave the rest as-is. + +For example + +```ts +type capitalized = Capitalize<'hello world'> // expected to be 'Hello world' +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/110-medium-capitalize/README.zh-CN.md b/questions/00110-medium-capitalize/README.zh-CN.md similarity index 100% rename from questions/110-medium-capitalize/README.zh-CN.md rename to questions/00110-medium-capitalize/README.zh-CN.md diff --git a/questions/110-medium-capitalize/info.yml b/questions/00110-medium-capitalize/info.yml similarity index 100% rename from questions/110-medium-capitalize/info.yml rename to questions/00110-medium-capitalize/info.yml diff --git a/questions/110-medium-capitalize/template.ts b/questions/00110-medium-capitalize/template.ts similarity index 100% rename from questions/110-medium-capitalize/template.ts rename to questions/00110-medium-capitalize/template.ts diff --git a/questions/110-medium-capitalize/test-cases.ts b/questions/00110-medium-capitalize/test-cases.ts similarity index 97% rename from questions/110-medium-capitalize/test-cases.ts rename to questions/00110-medium-capitalize/test-cases.ts index e8a06dc8a..ac965694c 100644 --- a/questions/110-medium-capitalize/test-cases.ts +++ b/questions/00110-medium-capitalize/test-cases.ts @@ -1,34 +1,34 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'Foobar'>>, - Expect, 'FOOBAR'>>, - Expect, 'Foo bar'>>, - Expect, ''>>, - Expect, 'A'>>, - Expect, 'B'>>, - Expect, 'C'>>, - Expect, 'D'>>, - Expect, 'E'>>, - Expect, 'F'>>, - Expect, 'G'>>, - Expect, 'H'>>, - Expect, 'I'>>, - Expect, 'J'>>, - Expect, 'K'>>, - Expect, 'L'>>, - Expect, 'M'>>, - Expect, 'N'>>, - Expect, 'O'>>, - Expect, 'P'>>, - Expect, 'Q'>>, - Expect, 'R'>>, - Expect, 'S'>>, - Expect, 'T'>>, - Expect, 'U'>>, - Expect, 'V'>>, - Expect, 'W'>>, - Expect, 'X'>>, - Expect, 'Y'>>, - Expect, 'Z'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'Foobar'>>, + Expect, 'FOOBAR'>>, + Expect, 'Foo bar'>>, + Expect, ''>>, + Expect, 'A'>>, + Expect, 'B'>>, + Expect, 'C'>>, + Expect, 'D'>>, + Expect, 'E'>>, + Expect, 'F'>>, + Expect, 'G'>>, + Expect, 'H'>>, + Expect, 'I'>>, + Expect, 'J'>>, + Expect, 'K'>>, + Expect, 'L'>>, + Expect, 'M'>>, + Expect, 'N'>>, + Expect, 'O'>>, + Expect, 'P'>>, + Expect, 'Q'>>, + Expect, 'R'>>, + Expect, 'S'>>, + Expect, 'T'>>, + Expect, 'U'>>, + Expect, 'V'>>, + Expect, 'W'>>, + Expect, 'X'>>, + Expect, 'Y'>>, + Expect, 'Z'>>, +] diff --git a/questions/112-hard-capitalizewords/README.ja.md b/questions/00112-hard-capitalizewords/README.ja.md similarity index 100% rename from questions/112-hard-capitalizewords/README.ja.md rename to questions/00112-hard-capitalizewords/README.ja.md diff --git a/questions/112-hard-capitalizewords/README.md b/questions/00112-hard-capitalizewords/README.md similarity index 99% rename from questions/112-hard-capitalizewords/README.md rename to questions/00112-hard-capitalizewords/README.md index 492b65350..0b22051f0 100644 --- a/questions/112-hard-capitalizewords/README.md +++ b/questions/00112-hard-capitalizewords/README.md @@ -1,12 +1,12 @@ -

Capitalize Words hard #template-literal

by Anthony Fu @antfu

Take the Challenge    日本語

- -Implement `CapitalizeWords` which converts the first letter of **each word of a string** to uppercase and leaves the rest as-is. - -For example - -```ts -type capitalized = CapitalizeWords<'hello world, my friends'> // expected to be 'Hello World, My Friends' -``` - - -
Back Share your Solutions Check out Solutions +

Capitalize Words hard #template-literal

by Anthony Fu @antfu

Take the Challenge    日本語

+ +Implement `CapitalizeWords` which converts the first letter of **each word of a string** to uppercase and leaves the rest as-is. + +For example + +```ts +type capitalized = CapitalizeWords<'hello world, my friends'> // expected to be 'Hello World, My Friends' +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/112-hard-capitalizewords/info.yml b/questions/00112-hard-capitalizewords/info.yml similarity index 100% rename from questions/112-hard-capitalizewords/info.yml rename to questions/00112-hard-capitalizewords/info.yml diff --git a/questions/112-hard-capitalizewords/template.ts b/questions/00112-hard-capitalizewords/template.ts similarity index 100% rename from questions/112-hard-capitalizewords/template.ts rename to questions/00112-hard-capitalizewords/template.ts diff --git a/questions/112-hard-capitalizewords/test-cases.ts b/questions/00112-hard-capitalizewords/test-cases.ts similarity index 98% rename from questions/112-hard-capitalizewords/test-cases.ts rename to questions/00112-hard-capitalizewords/test-cases.ts index 8ce99e4ba..d0e8592f2 100644 --- a/questions/112-hard-capitalizewords/test-cases.ts +++ b/questions/00112-hard-capitalizewords/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'Foobar'>>, - Expect, 'FOOBAR'>>, - Expect, 'Foo Bar'>>, - Expect, 'Foo Bar Hello World'>>, - Expect, 'Foo Bar.Hello,World'>>, - Expect, ''>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'Foobar'>>, + Expect, 'FOOBAR'>>, + Expect, 'Foo Bar'>>, + Expect, 'Foo Bar Hello World'>>, + Expect, 'Foo Bar.Hello,World'>>, + Expect, ''>>, ] diff --git a/questions/114-hard-camelcase/README.ja.md b/questions/00114-hard-camelcase/README.ja.md similarity index 79% rename from questions/114-hard-camelcase/README.ja.md rename to questions/00114-hard-camelcase/README.ja.md index 3d53e48eb..6884d71a6 100644 --- a/questions/114-hard-camelcase/README.ja.md +++ b/questions/00114-hard-camelcase/README.ja.md @@ -10,4 +10,4 @@ type camelCase2 = CamelCase<'HELLO_WORLD_WITH_TYPES'> // expected to be same as ``` -
戻る 解答を共有 解答を確認

関連する課題

610・CamelCase 612・KebabCase +
戻る 解答を共有 解答を確認

関連する課題

610・CamelCase 612・KebabCase diff --git a/questions/114-hard-camelcase/README.md b/questions/00114-hard-camelcase/README.md similarity index 77% rename from questions/114-hard-camelcase/README.md rename to questions/00114-hard-camelcase/README.md index 7cde5949c..2621c5d46 100644 --- a/questions/114-hard-camelcase/README.md +++ b/questions/00114-hard-camelcase/README.md @@ -1,13 +1,13 @@ -

CamelCase hard #template-literal

by Anthony Fu @antfu

Take the Challenge    日本語

- -Implement `CamelCase` which converts `snake_case` string to `camelCase`. - -For example - -```ts -type camelCase1 = CamelCase<'hello_world_with_types'> // expected to be 'helloWorldWithTypes' -type camelCase2 = CamelCase<'HELLO_WORLD_WITH_TYPES'> // expected to be same as previous one -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

610・CamelCase 612・KebabCase +

CamelCase hard #template-literal

by Anthony Fu @antfu

Take the Challenge    日本語

+ +Implement `CamelCase` which converts `snake_case` string to `camelCase`. + +For example + +```ts +type camelCase1 = CamelCase<'hello_world_with_types'> // expected to be 'helloWorldWithTypes' +type camelCase2 = CamelCase<'HELLO_WORLD_WITH_TYPES'> // expected to be same as previous one +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

610・CamelCase 612・KebabCase diff --git a/questions/114-hard-camelcase/info.yml b/questions/00114-hard-camelcase/info.yml similarity index 100% rename from questions/114-hard-camelcase/info.yml rename to questions/00114-hard-camelcase/info.yml diff --git a/questions/114-hard-camelcase/template.ts b/questions/00114-hard-camelcase/template.ts similarity index 100% rename from questions/114-hard-camelcase/template.ts rename to questions/00114-hard-camelcase/template.ts diff --git a/questions/114-hard-camelcase/test-cases.ts b/questions/00114-hard-camelcase/test-cases.ts similarity index 97% rename from questions/114-hard-camelcase/test-cases.ts rename to questions/00114-hard-camelcase/test-cases.ts index c1f32aea1..7c488d7e6 100644 --- a/questions/114-hard-camelcase/test-cases.ts +++ b/questions/00114-hard-camelcase/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'foobar'>>, - Expect, 'foobar'>>, - Expect, 'fooBar'>>, - Expect, 'fooBarHelloWorld'>>, - Expect, 'helloWorldWithTypes'>>, - Expect, ''>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'foobar'>>, + Expect, 'foobar'>>, + Expect, 'fooBar'>>, + Expect, 'fooBarHelloWorld'>>, + Expect, 'helloWorldWithTypes'>>, + Expect, ''>>, ] diff --git a/questions/116-medium-replace/README.ja.md b/questions/00116-medium-replace/README.ja.md similarity index 99% rename from questions/116-medium-replace/README.ja.md rename to questions/00116-medium-replace/README.ja.md index b533842d0..ef1ec8782 100644 --- a/questions/116-medium-replace/README.ja.md +++ b/questions/00116-medium-replace/README.ja.md @@ -1,11 +1,11 @@ -

Replace 中級 #template-literal

by Anthony Fu @antfu

挑戦する    English 简体中文

- -文字列`S`に含まれる文字`From`を`To`に一度だけ置き換える型`Replace`を実装します。 - -例えば - -```ts -type replaced = Replace<'types are fun!', 'fun', 'awesome'>; // expected to be 'types are awesome!' -``` - -
戻る 解答を共有 解答を確認 +

Replace 中級 #template-literal

by Anthony Fu @antfu

挑戦する    English 简体中文

+ +文字列`S`に含まれる文字`From`を`To`に一度だけ置き換える型`Replace`を実装します。 + +例えば + +```ts +type replaced = Replace<'types are fun!', 'fun', 'awesome'>; // expected to be 'types are awesome!' +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/116-medium-replace/README.md b/questions/00116-medium-replace/README.md similarity index 99% rename from questions/116-medium-replace/README.md rename to questions/00116-medium-replace/README.md index 392501873..1006052a2 100644 --- a/questions/116-medium-replace/README.md +++ b/questions/00116-medium-replace/README.md @@ -1,12 +1,12 @@ -

Replace medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Implement `Replace` which replace the string `From` with `To` once in the given string `S` - -For example - -```ts -type replaced = Replace<'types are fun!', 'fun', 'awesome'> // expected to be 'types are awesome!' -``` - - -
Back Share your Solutions Check out Solutions +

Replace medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Implement `Replace` which replace the string `From` with `To` once in the given string `S` + +For example + +```ts +type replaced = Replace<'types are fun!', 'fun', 'awesome'> // expected to be 'types are awesome!' +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/116-medium-replace/README.zh-CN.md b/questions/00116-medium-replace/README.zh-CN.md similarity index 99% rename from questions/116-medium-replace/README.zh-CN.md rename to questions/00116-medium-replace/README.zh-CN.md index 124e7d1c7..e582b06e6 100644 --- a/questions/116-medium-replace/README.zh-CN.md +++ b/questions/00116-medium-replace/README.zh-CN.md @@ -1,12 +1,12 @@ -

Replace 中等 #template-literal

by Anthony Fu @antfu

接受挑战    English 日本語

- -实现 `Replace` 将字符串 `S` 中的第一个子字符串 `From` 替换为 `To` 。 - -例如 - -```ts -type replaced = Replace<'types are fun!', 'fun', 'awesome'> // 期望是 'types are awesome!' -``` - - -
返回首页 分享你的解答 查看解答 +

Replace 中等 #template-literal

by Anthony Fu @antfu

接受挑战    English 日本語

+ +实现 `Replace` 将字符串 `S` 中的第一个子字符串 `From` 替换为 `To` 。 + +例如 + +```ts +type replaced = Replace<'types are fun!', 'fun', 'awesome'> // 期望是 'types are awesome!' +``` + + +
返回首页 分享你的解答 查看解答 diff --git a/questions/116-medium-replace/info.yml b/questions/00116-medium-replace/info.yml similarity index 100% rename from questions/116-medium-replace/info.yml rename to questions/00116-medium-replace/info.yml diff --git a/questions/116-medium-replace/template.ts b/questions/00116-medium-replace/template.ts similarity index 100% rename from questions/116-medium-replace/template.ts rename to questions/00116-medium-replace/template.ts diff --git a/questions/116-medium-replace/test-cases.ts b/questions/00116-medium-replace/test-cases.ts similarity index 97% rename from questions/116-medium-replace/test-cases.ts rename to questions/00116-medium-replace/test-cases.ts index d973790e8..64693c3f1 100644 --- a/questions/116-medium-replace/test-cases.ts +++ b/questions/00116-medium-replace/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'foofoo'>>, - Expect, 'foofoobar'>>, - Expect, 'foobarbar'>>, - Expect, 'foobarbar'>>, - Expect, ''>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'foofoo'>>, + Expect, 'foofoobar'>>, + Expect, 'foobarbar'>>, + Expect, 'foobarbar'>>, + Expect, ''>>, +] diff --git a/questions/119-medium-replaceall/README.ja.md b/questions/00119-medium-replaceall/README.ja.md similarity index 99% rename from questions/119-medium-replaceall/README.ja.md rename to questions/00119-medium-replaceall/README.ja.md index 143ea15f5..fc83bea6e 100644 --- a/questions/119-medium-replaceall/README.ja.md +++ b/questions/00119-medium-replaceall/README.ja.md @@ -1,11 +1,11 @@ -

ReplaceAll 中級 #template-literal

by Anthony Fu @antfu

挑戦する    English 简体中文

- -文字列`S`に含まれる部分文字列`From`を`To`に置き換える型`ReplaceAll`を実装します。 - -例えば - -```ts -type replaced = ReplaceAll<'t y p e s', ' ', ''>; // expected to be 'types' -``` - -
戻る 解答を共有 解答を確認 +

ReplaceAll 中級 #template-literal

by Anthony Fu @antfu

挑戦する    English 简体中文

+ +文字列`S`に含まれる部分文字列`From`を`To`に置き換える型`ReplaceAll`を実装します。 + +例えば + +```ts +type replaced = ReplaceAll<'t y p e s', ' ', ''>; // expected to be 'types' +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/119-medium-replaceall/README.md b/questions/00119-medium-replaceall/README.md similarity index 99% rename from questions/119-medium-replaceall/README.md rename to questions/00119-medium-replaceall/README.md index 7407754e7..0d5f6fc31 100644 --- a/questions/119-medium-replaceall/README.md +++ b/questions/00119-medium-replaceall/README.md @@ -1,12 +1,12 @@ -

ReplaceAll medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

- -Implement `ReplaceAll` which replace the all the substring `From` with `To` in the given string `S` - -For example - -```ts -type replaced = ReplaceAll<'t y p e s', ' ', ''> // expected to be 'types' -``` - - -
Back Share your Solutions Check out Solutions +

ReplaceAll medium #template-literal

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

+ +Implement `ReplaceAll` which replace the all the substring `From` with `To` in the given string `S` + +For example + +```ts +type replaced = ReplaceAll<'t y p e s', ' ', ''> // expected to be 'types' +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/119-medium-replaceall/README.zh-CN.md b/questions/00119-medium-replaceall/README.zh-CN.md similarity index 99% rename from questions/119-medium-replaceall/README.zh-CN.md rename to questions/00119-medium-replaceall/README.zh-CN.md index 489dbf25b..107d8563f 100644 --- a/questions/119-medium-replaceall/README.zh-CN.md +++ b/questions/00119-medium-replaceall/README.zh-CN.md @@ -1,11 +1,11 @@ -

ReplaceAll 中等 #template-literal

by Anthony Fu @antfu

接受挑战    English 日本語

- -实现 `ReplaceAll` 将一个字符串 `S` 中的所有子字符串 `From` 替换为 `To`。 - -例如 - -```ts -type replaced = ReplaceAll<'t y p e s', ' ', ''> // 期望是 'types' -``` - -
返回首页 分享你的解答 查看解答 +

ReplaceAll 中等 #template-literal

by Anthony Fu @antfu

接受挑战    English 日本語

+ +实现 `ReplaceAll` 将一个字符串 `S` 中的所有子字符串 `From` 替换为 `To`。 + +例如 + +```ts +type replaced = ReplaceAll<'t y p e s', ' ', ''> // 期望是 'types' +``` + +
返回首页 分享你的解答 查看解答 diff --git a/questions/119-medium-replaceall/info.yml b/questions/00119-medium-replaceall/info.yml similarity index 100% rename from questions/119-medium-replaceall/info.yml rename to questions/00119-medium-replaceall/info.yml diff --git a/questions/119-medium-replaceall/template.ts b/questions/00119-medium-replaceall/template.ts similarity index 100% rename from questions/119-medium-replaceall/template.ts rename to questions/00119-medium-replaceall/template.ts diff --git a/questions/119-medium-replaceall/test-cases.ts b/questions/00119-medium-replaceall/test-cases.ts similarity index 98% rename from questions/119-medium-replaceall/test-cases.ts rename to questions/00119-medium-replaceall/test-cases.ts index ff1f4d38a..90e9610d1 100644 --- a/questions/119-medium-replaceall/test-cases.ts +++ b/questions/00119-medium-replaceall/test-cases.ts @@ -1,13 +1,13 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'foofoo'>>, - Expect, 'foobar'>>, - Expect, 'foofoofoo'>>, - Expect, 'types'>>, - Expect, 'foobarbar'>>, - Expect, 'foofoo'>>, - Expect, 'fobarfobar'>>, - Expect, 'foborfobar'>>, - Expect, ''>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'foofoo'>>, + Expect, 'foobar'>>, + Expect, 'foofoofoo'>>, + Expect, 'types'>>, + Expect, 'foobarbar'>>, + Expect, 'foofoo'>>, + Expect, 'fobarfobar'>>, + Expect, 'foborfobar'>>, + Expect, ''>>, +] diff --git a/questions/147-hard-c-printf-parser/README.ja.md b/questions/00147-hard-c-printf-parser/README.ja.md similarity index 98% rename from questions/147-hard-c-printf-parser/README.ja.md rename to questions/00147-hard-c-printf-parser/README.ja.md index dc96f289a..c8c3e934c 100644 --- a/questions/147-hard-c-printf-parser/README.ja.md +++ b/questions/00147-hard-c-printf-parser/README.ja.md @@ -1,26 +1,26 @@ -

C-printf Parser 上級 #template-literal

by Pig Fang @g-plane

挑戦する    English

- -C 言語には`printf`という関数があり、以下のようにフォーマットして出力してくれます。 - -```c -printf("The result is %d.", 42); -``` - -この課題では、入力値の文字列をパースして`%d`や`%f`のようなフォーマットのプレースホルダーを抜き出します。 -例えば、もし入力文字列が`"The result is %d"`であるなら、パースした結果は`['dec']`というタプルになります。 - -マッピングは以下となります。 - -```typescript -type ControlsMap = { - c: 'char'; - s: 'string'; - d: 'dec'; - o: 'oct'; - h: 'hex'; - f: 'float'; - p: 'pointer'; -}; -``` - -
戻る 解答を共有 解答を確認 +

C-printf Parser 上級 #template-literal

by Pig Fang @g-plane

挑戦する    English

+ +C 言語には`printf`という関数があり、以下のようにフォーマットして出力してくれます。 + +```c +printf("The result is %d.", 42); +``` + +この課題では、入力値の文字列をパースして`%d`や`%f`のようなフォーマットのプレースホルダーを抜き出します。 +例えば、もし入力文字列が`"The result is %d"`であるなら、パースした結果は`['dec']`というタプルになります。 + +マッピングは以下となります。 + +```typescript +type ControlsMap = { + c: 'char'; + s: 'string'; + d: 'dec'; + o: 'oct'; + h: 'hex'; + f: 'float'; + p: 'pointer'; +}; +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/147-hard-c-printf-parser/README.md b/questions/00147-hard-c-printf-parser/README.md similarity index 98% rename from questions/147-hard-c-printf-parser/README.md rename to questions/00147-hard-c-printf-parser/README.md index 32145e0ac..7c425f1fe 100644 --- a/questions/147-hard-c-printf-parser/README.md +++ b/questions/00147-hard-c-printf-parser/README.md @@ -1,25 +1,25 @@

C-printf Parser hard #template-literal

by Pig Fang @g-plane

Take the Challenge    日本語

-There is a function in C language: `printf`. This function allows us to print something with formatting. Like this: - -```c -printf("The result is %d.", 42); -``` - -This challenge requires you to parse the input string and extract the format placeholders like `%d` and `%f`. For example, if the input string is `"The result is %d."`, the parsed result is a tuple `['dec']`. - -Here is the mapping: - -```typescript -type ControlsMap = { - c: 'char', - s: 'string', - d: 'dec', - o: 'oct', - h: 'hex', - f: 'float', - p: 'pointer', -} +There is a function in C language: `printf`. This function allows us to print something with formatting. Like this: + +```c +printf("The result is %d.", 42); +``` + +This challenge requires you to parse the input string and extract the format placeholders like `%d` and `%f`. For example, if the input string is `"The result is %d."`, the parsed result is a tuple `['dec']`. + +Here is the mapping: + +```typescript +type ControlsMap = { + c: 'char', + s: 'string', + d: 'dec', + o: 'oct', + h: 'hex', + f: 'float', + p: 'pointer', +} ``` diff --git a/questions/147-hard-c-printf-parser/info.yml b/questions/00147-hard-c-printf-parser/info.yml similarity index 100% rename from questions/147-hard-c-printf-parser/info.yml rename to questions/00147-hard-c-printf-parser/info.yml diff --git a/questions/147-hard-c-printf-parser/template.ts b/questions/00147-hard-c-printf-parser/template.ts similarity index 93% rename from questions/147-hard-c-printf-parser/template.ts rename to questions/00147-hard-c-printf-parser/template.ts index 20af73b84..baba70cf7 100644 --- a/questions/147-hard-c-printf-parser/template.ts +++ b/questions/00147-hard-c-printf-parser/template.ts @@ -1,11 +1,11 @@ -type ControlsMap = { - c: 'char' - s: 'string' - d: 'dec' - o: 'oct' - h: 'hex' - f: 'float' - p: 'pointer' -} - +type ControlsMap = { + c: 'char' + s: 'string' + d: 'dec' + o: 'oct' + h: 'hex' + f: 'float' + p: 'pointer' +} + type ParsePrintFormat = any diff --git a/questions/147-hard-c-printf-parser/test-cases.ts b/questions/00147-hard-c-printf-parser/test-cases.ts similarity index 98% rename from questions/147-hard-c-printf-parser/test-cases.ts rename to questions/00147-hard-c-printf-parser/test-cases.ts index cb0b55923..33c63b6dd 100644 --- a/questions/147-hard-c-printf-parser/test-cases.ts +++ b/questions/00147-hard-c-printf-parser/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, []>>, - Expect, ['dec']>>, - Expect, []>>, - Expect, ['dec']>>, - Expect, ['float']>>, - Expect, ['hex']>>, - Expect, []>>, - Expect, ['string', 'dec']>>, - Expect, []>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, []>>, + Expect, ['dec']>>, + Expect, []>>, + Expect, ['dec']>>, + Expect, ['float']>>, + Expect, ['hex']>>, + Expect, []>>, + Expect, ['string', 'dec']>>, + Expect, []>>, ] diff --git a/questions/151-extreme-query-string-parser/README.md b/questions/00151-extreme-query-string-parser/README.md similarity index 99% rename from questions/151-extreme-query-string-parser/README.md rename to questions/00151-extreme-query-string-parser/README.md index ee4773a00..0ce66cca8 100644 --- a/questions/151-extreme-query-string-parser/README.md +++ b/questions/00151-extreme-query-string-parser/README.md @@ -1,12 +1,12 @@

Query String Parser extreme #template-literal

by Pig Fang @g-plane

Take the Challenge

-You're required to implement a type-level parser to parse URL query string into a object literal type. - -Some detailed requirements: - -- Value of a key in query string can be ignored but still be parsed to `true`. For example, `'key'` is without value, so the parser result is `{ key: true }`. -- Duplicated keys must be merged into one. If there are different values with the same key, values must be merged into a tuple type. -- When a key has only one value, that value can't be wrapped into a tuple type. +You're required to implement a type-level parser to parse URL query string into a object literal type. + +Some detailed requirements: + +- Value of a key in query string can be ignored but still be parsed to `true`. For example, `'key'` is without value, so the parser result is `{ key: true }`. +- Duplicated keys must be merged into one. If there are different values with the same key, values must be merged into a tuple type. +- When a key has only one value, that value can't be wrapped into a tuple type. - If values with the same key appear more than once, it must be treated as once. For example, `key=value&key=value` must be treated as `key=value` only. diff --git a/questions/151-extreme-query-string-parser/info.yml b/questions/00151-extreme-query-string-parser/info.yml similarity index 100% rename from questions/151-extreme-query-string-parser/info.yml rename to questions/00151-extreme-query-string-parser/info.yml diff --git a/questions/151-extreme-query-string-parser/template.ts b/questions/00151-extreme-query-string-parser/template.ts similarity index 100% rename from questions/151-extreme-query-string-parser/template.ts rename to questions/00151-extreme-query-string-parser/template.ts diff --git a/questions/151-extreme-query-string-parser/test-cases.ts b/questions/00151-extreme-query-string-parser/test-cases.ts similarity index 98% rename from questions/151-extreme-query-string-parser/test-cases.ts rename to questions/00151-extreme-query-string-parser/test-cases.ts index a1abe24e9..ec8cf8a0b 100644 --- a/questions/151-extreme-query-string-parser/test-cases.ts +++ b/questions/00151-extreme-query-string-parser/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, {}>>, - Expect, { k1: true }>>, - Expect, { k1: true }>>, - Expect, { k1: true; k2: true }>>, - Expect, { k1: 'v1' }>>, - Expect, { k1: ['v1', 'v2'] }>>, - Expect, { k1: 'v1'; k2: 'v2' }>>, - Expect, { k1: ['v1', 'v2']; k2: 'v2' }>>, - Expect, { k1: 'v1'; k2: true }>>, - Expect, { k1: 'v1' }>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, {}>>, + Expect, { k1: true }>>, + Expect, { k1: true }>>, + Expect, { k1: true; k2: true }>>, + Expect, { k1: 'v1' }>>, + Expect, { k1: ['v1', 'v2'] }>>, + Expect, { k1: 'v1'; k2: 'v2' }>>, + Expect, { k1: ['v1', 'v2']; k2: 'v2' }>>, + Expect, { k1: 'v1'; k2: true }>>, + Expect, { k1: 'v1' }>>, ] diff --git a/questions/189-easy-awaited/README.ja.md b/questions/00189-easy-awaited/README.ja.md similarity index 100% rename from questions/189-easy-awaited/README.ja.md rename to questions/00189-easy-awaited/README.ja.md diff --git a/questions/189-easy-awaited/README.ko.md b/questions/00189-easy-awaited/README.ko.md similarity index 100% rename from questions/189-easy-awaited/README.ko.md rename to questions/00189-easy-awaited/README.ko.md diff --git a/questions/189-easy-awaited/README.md b/questions/00189-easy-awaited/README.md similarity index 100% rename from questions/189-easy-awaited/README.md rename to questions/00189-easy-awaited/README.md diff --git a/questions/189-easy-awaited/README.zh-CN.md b/questions/00189-easy-awaited/README.zh-CN.md similarity index 100% rename from questions/189-easy-awaited/README.zh-CN.md rename to questions/00189-easy-awaited/README.zh-CN.md diff --git a/questions/189-easy-awaited/info.yml b/questions/00189-easy-awaited/info.yml similarity index 100% rename from questions/189-easy-awaited/info.yml rename to questions/00189-easy-awaited/info.yml diff --git a/questions/189-easy-awaited/template.ts b/questions/00189-easy-awaited/template.ts similarity index 100% rename from questions/189-easy-awaited/template.ts rename to questions/00189-easy-awaited/template.ts diff --git a/questions/189-easy-awaited/test-cases.ts b/questions/00189-easy-awaited/test-cases.ts similarity index 96% rename from questions/189-easy-awaited/test-cases.ts rename to questions/00189-easy-awaited/test-cases.ts index 282a1b328..989cb2b77 100644 --- a/questions/189-easy-awaited/test-cases.ts +++ b/questions/00189-easy-awaited/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type X = Promise -type Y = Promise<{ field: number }> -type Z = Promise> - -type cases = [ - Expect, string>>, - Expect, { field: number }>>, - Expect, string | number>>, -] - -// @ts-expect-error -type error = MyAwaited +import type { Equal, Expect } from '@type-challenges/utils' + +type X = Promise +type Y = Promise<{ field: number }> +type Z = Promise> + +type cases = [ + Expect, string>>, + Expect, { field: number }>>, + Expect, string | number>>, +] + +// @ts-expect-error +type error = MyAwaited diff --git a/questions/191-medium-append-argument/README.ja.md b/questions/00191-medium-append-argument/README.ja.md similarity index 100% rename from questions/191-medium-append-argument/README.ja.md rename to questions/00191-medium-append-argument/README.ja.md diff --git a/questions/191-medium-append-argument/README.md b/questions/00191-medium-append-argument/README.md similarity index 100% rename from questions/191-medium-append-argument/README.md rename to questions/00191-medium-append-argument/README.md diff --git a/questions/191-medium-append-argument/README.zh-CN.md b/questions/00191-medium-append-argument/README.zh-CN.md similarity index 99% rename from questions/191-medium-append-argument/README.zh-CN.md rename to questions/00191-medium-append-argument/README.zh-CN.md index 344361077..3155b3009 100644 --- a/questions/191-medium-append-argument/README.zh-CN.md +++ b/questions/00191-medium-append-argument/README.zh-CN.md @@ -1,16 +1,16 @@ -

追加参数 中等 #arguments

by Maciej Sikora @maciejsikora

接受挑战    English 日本語

- -> 由 @antfu 翻译 - -实现一个泛型 `AppendArgument`,对于给定的函数类型 `Fn`,以及一个任意类型 `A`,返回一个新的函数 `G`。`G` 拥有 `Fn` 的所有参数并在末尾追加类型为 `A` 的参数。 - -```typescript -type Fn = (a: number, b: string) => number - -type Result = AppendArgument -// 期望是 (a: number, b: string, x: boolean) => number -``` - -> 本挑战来自于 [@maciejsikora](https://github.com/maciejsikora) 在 Dev.io 上的[文章](https://dev.to/macsikora/advanced-typescript-exercises-question-4-495c) - -
返回首页 分享你的解答 查看解答 +

追加参数 中等 #arguments

by Maciej Sikora @maciejsikora

接受挑战    English 日本語

+ +> 由 @antfu 翻译 + +实现一个泛型 `AppendArgument`,对于给定的函数类型 `Fn`,以及一个任意类型 `A`,返回一个新的函数 `G`。`G` 拥有 `Fn` 的所有参数并在末尾追加类型为 `A` 的参数。 + +```typescript +type Fn = (a: number, b: string) => number + +type Result = AppendArgument +// 期望是 (a: number, b: string, x: boolean) => number +``` + +> 本挑战来自于 [@maciejsikora](https://github.com/maciejsikora) 在 Dev.io 上的[文章](https://dev.to/macsikora/advanced-typescript-exercises-question-4-495c) + +
返回首页 分享你的解答 查看解答 diff --git a/questions/191-medium-append-argument/info.yml b/questions/00191-medium-append-argument/info.yml similarity index 100% rename from questions/191-medium-append-argument/info.yml rename to questions/00191-medium-append-argument/info.yml diff --git a/questions/191-medium-append-argument/info.zh-CN.yml b/questions/00191-medium-append-argument/info.zh-CN.yml similarity index 100% rename from questions/191-medium-append-argument/info.zh-CN.yml rename to questions/00191-medium-append-argument/info.zh-CN.yml diff --git a/questions/191-medium-append-argument/template.ts b/questions/00191-medium-append-argument/template.ts similarity index 100% rename from questions/191-medium-append-argument/template.ts rename to questions/00191-medium-append-argument/template.ts diff --git a/questions/191-medium-append-argument/test-cases.ts b/questions/00191-medium-append-argument/test-cases.ts similarity index 96% rename from questions/191-medium-append-argument/test-cases.ts rename to questions/00191-medium-append-argument/test-cases.ts index a4711680e..229a0f11a 100644 --- a/questions/191-medium-append-argument/test-cases.ts +++ b/questions/00191-medium-append-argument/test-cases.ts @@ -1,12 +1,12 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Case1 = AppendArgument<(a: number, b: string) => number, boolean> -type Result1 = (a: number, b: string, x: boolean) => number - -type Case2 = AppendArgument<() => void, undefined> -type Result2 = (x: undefined) => void - -type cases = [ - Expect>, - Expect>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Case1 = AppendArgument<(a: number, b: string) => number, boolean> +type Result1 = (a: number, b: string, x: boolean) => number + +type Case2 = AppendArgument<() => void, undefined> +type Result2 = (x: undefined) => void + +type cases = [ + Expect>, + Expect>, +] diff --git a/questions/213-hard-vue-basic-props/README.ja.md b/questions/00213-hard-vue-basic-props/README.ja.md similarity index 92% rename from questions/213-hard-vue-basic-props/README.ja.md rename to questions/00213-hard-vue-basic-props/README.ja.md index f7bd711f3..7d9896b02 100644 --- a/questions/213-hard-vue-basic-props/README.ja.md +++ b/questions/00213-hard-vue-basic-props/README.ja.md @@ -1,44 +1,44 @@ -

Vue Basic Props 上級 #vue #application

by Anthony Fu @antfu

挑戦する    English

- - -**この問題は [6 - Simple Vue](//tsch.js.org/6) の続きです。 先にその問題を解いた上で、そこで得られるコードを基盤にしてこの問題に取り組んでください。** - -Simple Vue に加え、我々は 新しく `props` フィールドをオプションとして利用できます。これは Vue の `props` オプションを更に簡潔にしたものです。利用するにはいくつかのルールがあります。 - -`props` は、 `this` に挿入された各々のフィールドをキーをとして保持するオブジェクトです。挿入された props は `data`,`computed`, `methods` などを始めとした 全ての環境からアクセス可能になります。 - -prop は コンストラクタ、または コンストラクタを含んだ `type` フィールドを持つオブジェクトで定義されます。 - -例) - -```js -props: { - foo: Boolean -} -// or -props: { - foo: { type: Boolean } -} -``` - -これらは `type Props = { foo: boolean }` であると推測されます。 - -複数の型を渡した場合、Props の型は ユニオン型として推測されます。 - -```ts -props: { - foo: { type: [Boolean, Number, String] } -} -// --> -type Props = { foo: boolean | number | string } -``` - -空のオブジェクトが渡された場合、対象のkeyは `any` 型として推測されます。 - - -より具体的なケースについては, Test Cases セクションを参照してください。 - ->Vue の `required`, `default`, そして 配列の props はこの問題において考慮されておりません. - - -
戻る 解答を共有 解答を確認

関連する課題

6・Simple Vue \ No newline at end of file +

Vue Basic Props 上級 #vue #application

by Anthony Fu @antfu

挑戦する    English

+ + +**この問題は [6 - Simple Vue](//tsch.js.org/6) の続きです。 先にその問題を解いた上で、そこで得られるコードを基盤にしてこの問題に取り組んでください。** + +Simple Vue に加え、我々は 新しく `props` フィールドをオプションとして利用できます。これは Vue の `props` オプションを更に簡潔にしたものです。利用するにはいくつかのルールがあります。 + +`props` は、 `this` に挿入された各々のフィールドをキーをとして保持するオブジェクトです。挿入された props は `data`,`computed`, `methods` などを始めとした 全ての環境からアクセス可能になります。 + +prop は コンストラクタ、または コンストラクタを含んだ `type` フィールドを持つオブジェクトで定義されます。 + +例) + +```js +props: { + foo: Boolean +} +// or +props: { + foo: { type: Boolean } +} +``` + +これらは `type Props = { foo: boolean }` であると推測されます。 + +複数の型を渡した場合、Props の型は ユニオン型として推測されます。 + +```ts +props: { + foo: { type: [Boolean, Number, String] } +} +// --> +type Props = { foo: boolean | number | string } +``` + +空のオブジェクトが渡された場合、対象のkeyは `any` 型として推測されます。 + + +より具体的なケースについては, Test Cases セクションを参照してください。 + +>Vue の `required`, `default`, そして 配列の props はこの問題において考慮されておりません. + + +
戻る 解答を共有 解答を確認

関連する課題

6・Simple Vue \ No newline at end of file diff --git a/questions/213-hard-vue-basic-props/README.md b/questions/00213-hard-vue-basic-props/README.md similarity index 91% rename from questions/213-hard-vue-basic-props/README.md rename to questions/00213-hard-vue-basic-props/README.md index 7966b9372..e2daf6e8c 100644 --- a/questions/213-hard-vue-basic-props/README.md +++ b/questions/00213-hard-vue-basic-props/README.md @@ -1,42 +1,42 @@

Vue Basic Props hard #vue #application

by Anthony Fu @antfu

Take the Challenge    日本語

-**This challenge continues from [6 - Simple Vue](//tsch.js.org/6), you should finish that one first, and modify your code based on it to start this challenge**. - -In addition to the Simple Vue, we are now having a new `props` field in the options. This is a simplified version of Vue's `props` option. Here are some of the rules. - -`props` is an object containing each field as the key of the real props injected into `this`. The injected props will be accessible in all the context including `data`, `computed`, and `methods`. - -A prop will be defined either by a constructor or an object with a `type` field containing constructor(s). - -For example - -```js -props: { - foo: Boolean -} -// or -props: { - foo: { type: Boolean } -} -``` - -should be inferred to `type Props = { foo: boolean }`. - -When passing multiple constructors, the type should be inferred to a union. - -```ts -props: { - foo: { type: [Boolean, Number, String] } -} -// --> -type Props = { foo: boolean | number | string } -``` - -When an empty object is passed, the key should be inferred to `any`. - -For more specified cases, check out the Test Cases section. - +**This challenge continues from [6 - Simple Vue](//tsch.js.org/6), you should finish that one first, and modify your code based on it to start this challenge**. + +In addition to the Simple Vue, we are now having a new `props` field in the options. This is a simplified version of Vue's `props` option. Here are some of the rules. + +`props` is an object containing each field as the key of the real props injected into `this`. The injected props will be accessible in all the context including `data`, `computed`, and `methods`. + +A prop will be defined either by a constructor or an object with a `type` field containing constructor(s). + +For example + +```js +props: { + foo: Boolean +} +// or +props: { + foo: { type: Boolean } +} +``` + +should be inferred to `type Props = { foo: boolean }`. + +When passing multiple constructors, the type should be inferred to a union. + +```ts +props: { + foo: { type: [Boolean, Number, String] } +} +// --> +type Props = { foo: boolean | number | string } +``` + +When an empty object is passed, the key should be inferred to `any`. + +For more specified cases, check out the Test Cases section. + > `required`, `default`, and array props in Vue are not considered in this challenge. -
Back Share your Solutions Check out Solutions

Related Challenges

6・Simple Vue \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

6・Simple Vue \ No newline at end of file diff --git a/questions/213-hard-vue-basic-props/info.yml b/questions/00213-hard-vue-basic-props/info.yml similarity index 100% rename from questions/213-hard-vue-basic-props/info.yml rename to questions/00213-hard-vue-basic-props/info.yml diff --git a/questions/213-hard-vue-basic-props/template.ts b/questions/00213-hard-vue-basic-props/template.ts similarity index 100% rename from questions/213-hard-vue-basic-props/template.ts rename to questions/00213-hard-vue-basic-props/template.ts diff --git a/questions/213-hard-vue-basic-props/test-cases.ts b/questions/00213-hard-vue-basic-props/test-cases.ts similarity index 95% rename from questions/213-hard-vue-basic-props/test-cases.ts rename to questions/00213-hard-vue-basic-props/test-cases.ts index 7f591a3eb..cf5c5cb7f 100644 --- a/questions/213-hard-vue-basic-props/test-cases.ts +++ b/questions/00213-hard-vue-basic-props/test-cases.ts @@ -1,60 +1,60 @@ -import type { Debug, Equal, Expect, IsAny } from '@type-challenges/utils' - -class ClassA {} - -VueBasicProps({ - props: { - propA: {}, - propB: { type: String }, - propC: { type: Boolean }, - propD: { type: ClassA }, - propE: { type: [String, Number] }, - propF: RegExp, - }, - data(this) { - type PropsType = Debug - type cases = [ - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - ] - - // @ts-expect-error - this.firstname - // @ts-expect-error - this.getRandom() - // @ts-expect-error - this.data() - - return { - firstname: 'Type', - lastname: 'Challenges', - amount: 10, - } - }, - computed: { - fullname() { - return `${this.firstname} ${this.lastname}` - }, - }, - methods: { - getRandom() { - return Math.random() - }, - hi() { - alert(this.fullname.toLowerCase()) - alert(this.getRandom()) - }, - test() { - const fullname = this.fullname - const propE = this.propE - type cases = [ - Expect>, - Expect>, - ] - }, - }, +import type { Debug, Equal, Expect, IsAny } from '@type-challenges/utils' + +class ClassA {} + +VueBasicProps({ + props: { + propA: {}, + propB: { type: String }, + propC: { type: Boolean }, + propD: { type: ClassA }, + propE: { type: [String, Number] }, + propF: RegExp, + }, + data(this) { + type PropsType = Debug + type cases = [ + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + ] + + // @ts-expect-error + this.firstname + // @ts-expect-error + this.getRandom() + // @ts-expect-error + this.data() + + return { + firstname: 'Type', + lastname: 'Challenges', + amount: 10, + } + }, + computed: { + fullname() { + return `${this.firstname} ${this.lastname}` + }, + }, + methods: { + getRandom() { + return Math.random() + }, + hi() { + alert(this.fullname.toLowerCase()) + alert(this.getRandom()) + }, + test() { + const fullname = this.fullname + const propE = this.propE + type cases = [ + Expect>, + Expect>, + ] + }, + }, }) diff --git a/questions/216-extreme-slice/README.md b/questions/00216-extreme-slice/README.md similarity index 99% rename from questions/216-extreme-slice/README.md rename to questions/00216-extreme-slice/README.md index 5c56edbc8..ae32d2a95 100644 --- a/questions/216-extreme-slice/README.md +++ b/questions/00216-extreme-slice/README.md @@ -1,12 +1,12 @@

Slice extreme #array

by Anthony Fu @antfu

Take the Challenge

-Implement the JavaScript `Array.slice` function in the type system. `Slice` takes the tree argument. The output should be a subarray of `Arr` from index `Start` to `End`. Indexes with negative numbers should be counted from reversely. - -For example - -```ts -type Arr = [1, 2, 3, 4, 5] -type Result = Slice // expected to be [3, 4] +Implement the JavaScript `Array.slice` function in the type system. `Slice` takes the tree argument. The output should be a subarray of `Arr` from index `Start` to `End`. Indexes with negative numbers should be counted from reversely. + +For example + +```ts +type Arr = [1, 2, 3, 4, 5] +type Result = Slice // expected to be [3, 4] ``` diff --git a/questions/216-extreme-slice/info.yml b/questions/00216-extreme-slice/info.yml similarity index 100% rename from questions/216-extreme-slice/info.yml rename to questions/00216-extreme-slice/info.yml diff --git a/questions/216-extreme-slice/template.ts b/questions/00216-extreme-slice/template.ts similarity index 100% rename from questions/216-extreme-slice/template.ts rename to questions/00216-extreme-slice/template.ts diff --git a/questions/216-extreme-slice/test-cases.ts b/questions/00216-extreme-slice/test-cases.ts similarity index 96% rename from questions/216-extreme-slice/test-cases.ts rename to questions/00216-extreme-slice/test-cases.ts index 6e73ecd37..c0ee1a066 100644 --- a/questions/216-extreme-slice/test-cases.ts +++ b/questions/00216-extreme-slice/test-cases.ts @@ -1,25 +1,25 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Arr = [1, 2, 3, 4, 5] - -type cases = [ - // basic - Expect, [1]>>, - Expect, []>>, - Expect, [3, 4]>>, - - // optional args - Expect, []>>, - Expect, Arr>>, - Expect, Arr>>, - Expect, [3, 4, 5]>>, - - // negative index - Expect, [1, 2, 3, 4]>>, - Expect, [3, 4]>>, - - // invalid - Expect, []>>, - Expect, []>>, - Expect, []>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Arr = [1, 2, 3, 4, 5] + +type cases = [ + // basic + Expect, [1]>>, + Expect, []>>, + Expect, [3, 4]>>, + + // optional args + Expect, []>>, + Expect, Arr>>, + Expect, Arr>>, + Expect, [3, 4, 5]>>, + + // negative index + Expect, [1, 2, 3, 4]>>, + Expect, [3, 4]>>, + + // invalid + Expect, []>>, + Expect, []>>, + Expect, []>>, +] diff --git a/questions/223-hard-isany/README.ja.md b/questions/00223-hard-isany/README.ja.md similarity index 74% rename from questions/223-hard-isany/README.ja.md rename to questions/00223-hard-isany/README.ja.md index 871a79fcc..1b2535c87 100644 --- a/questions/223-hard-isany/README.ja.md +++ b/questions/00223-hard-isany/README.ja.md @@ -5,4 +5,4 @@ そこで、型`T`を受け取るユーティリティ型`IsAny`を書いてみましょう。`T`が`any`型であれば`true`を返し、そうでなければ`false`を返します。 -
戻る 解答を共有 解答を確認

関連する課題

1042・IsNever 1097・IsUnion 4484・IsTuple +
戻る 解答を共有 解答を確認

関連する課題

1042・IsNever 1097・IsUnion 4484・IsTuple diff --git a/questions/223-hard-isany/README.md b/questions/00223-hard-isany/README.md similarity index 71% rename from questions/223-hard-isany/README.md rename to questions/00223-hard-isany/README.md index e91a2347e..3a553195e 100644 --- a/questions/223-hard-isany/README.md +++ b/questions/00223-hard-isany/README.md @@ -1,8 +1,8 @@

IsAny hard #utils

by Pavel Glushkov @pashutk

Take the Challenge    日本語

-Sometimes it's useful to detect if you have a value with `any` type. This is especially helpful while working with third-party Typescript modules, which can export `any` values in the module API. It's also good to know about `any` when you're suppressing implicitAny checks. - +Sometimes it's useful to detect if you have a value with `any` type. This is especially helpful while working with third-party Typescript modules, which can export `any` values in the module API. It's also good to know about `any` when you're suppressing implicitAny checks. + So, let's write a utility type `IsAny`, which takes input type `T`. If `T` is `any`, return `true`, otherwise, return `false`. -
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 1097・IsUnion 4484・IsTuple \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 1097・IsUnion 4484・IsTuple \ No newline at end of file diff --git a/questions/223-hard-isany/info.yml b/questions/00223-hard-isany/info.yml similarity index 100% rename from questions/223-hard-isany/info.yml rename to questions/00223-hard-isany/info.yml diff --git a/questions/223-hard-isany/template.ts b/questions/00223-hard-isany/template.ts similarity index 100% rename from questions/223-hard-isany/template.ts rename to questions/00223-hard-isany/template.ts diff --git a/questions/223-hard-isany/test-cases.ts b/questions/00223-hard-isany/test-cases.ts similarity index 96% rename from questions/223-hard-isany/test-cases.ts rename to questions/00223-hard-isany/test-cases.ts index 72f6e9563..92e46c1a2 100644 --- a/questions/223-hard-isany/test-cases.ts +++ b/questions/00223-hard-isany/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, ] diff --git a/questions/268-easy-if/README.ja.md b/questions/00268-easy-if/README.ja.md similarity index 99% rename from questions/268-easy-if/README.ja.md rename to questions/00268-easy-if/README.ja.md index 95f9632f5..c904fe811 100644 --- a/questions/268-easy-if/README.ja.md +++ b/questions/00268-easy-if/README.ja.md @@ -1,13 +1,13 @@ -

If 初級 #utils

by Pavel Glushkov @pashutk

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

- -条件値`C`、 `C`が truthy である場合の戻り値の型`T`、`C`が falsy である場合の戻り値の型`F`を受け取る`If`を実装します。 -条件値`C` は`true`か`false`のどちらかであることが期待されますが、`T` と `F` は任意の型をとることができます。 - -例えば - -```ts -type A = If; // expected to be 'a' -type B = If; // expected to be 'b' -``` - -
戻る 解答を共有 解答を確認 +

If 初級 #utils

by Pavel Glushkov @pashutk

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

+ +条件値`C`、 `C`が truthy である場合の戻り値の型`T`、`C`が falsy である場合の戻り値の型`F`を受け取る`If`を実装します。 +条件値`C` は`true`か`false`のどちらかであることが期待されますが、`T` と `F` は任意の型をとることができます。 + +例えば + +```ts +type A = If; // expected to be 'a' +type B = If; // expected to be 'b' +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/268-easy-if/README.ko.md b/questions/00268-easy-if/README.ko.md similarity index 99% rename from questions/268-easy-if/README.ko.md rename to questions/00268-easy-if/README.ko.md index 7f823fdb1..eea84a633 100644 --- a/questions/268-easy-if/README.ko.md +++ b/questions/00268-easy-if/README.ko.md @@ -1,13 +1,13 @@ -

If 쉬움 #utils

by Pavel Glushkov @pashutk

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

- -조건 `C`, 참일 때 반환하는 타입 `T`, 거짓일 때 반환하는 타입 `F`를 받는 타입 `If`를 구현하세요. `C`는 `true` 또는 `false`이고, `T`와 `F`는 아무 타입입니다. - -예시: - -```ts -type A = If // expected to be 'a' -type B = If // expected to be 'b' -``` - - +

If 쉬움 #utils

by Pavel Glushkov @pashutk

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

+ +조건 `C`, 참일 때 반환하는 타입 `T`, 거짓일 때 반환하는 타입 `F`를 받는 타입 `If`를 구현하세요. `C`는 `true` 또는 `false`이고, `T`와 `F`는 아무 타입입니다. + +예시: + +```ts +type A = If // expected to be 'a' +type B = If // expected to be 'b' +``` + +
돌아가기 정답 공유하기 정답 보기 \ No newline at end of file diff --git a/questions/268-easy-if/README.md b/questions/00268-easy-if/README.md similarity index 99% rename from questions/268-easy-if/README.md rename to questions/00268-easy-if/README.md index af4a0869b..6f1857d46 100644 --- a/questions/268-easy-if/README.md +++ b/questions/00268-easy-if/README.md @@ -1,12 +1,12 @@

If easy #utils

by Pavel Glushkov @pashutk

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

-Implement a utils `If` which accepts condition `C`, a truthy return type `T`, and a falsy return type `F`. `C` is expected to be either `true` or `false` while `T` and `F` can be any type. - -For example: - -```ts -type A = If // expected to be 'a' -type B = If // expected to be 'b' +Implement a utils `If` which accepts condition `C`, a truthy return type `T`, and a falsy return type `F`. `C` is expected to be either `true` or `false` while `T` and `F` can be any type. + +For example: + +```ts +type A = If // expected to be 'a' +type B = If // expected to be 'b' ``` diff --git a/questions/268-easy-if/README.zh-CN.md b/questions/00268-easy-if/README.zh-CN.md similarity index 99% rename from questions/268-easy-if/README.zh-CN.md rename to questions/00268-easy-if/README.zh-CN.md index b67efe03d..845196cff 100644 --- a/questions/268-easy-if/README.zh-CN.md +++ b/questions/00268-easy-if/README.zh-CN.md @@ -1,13 +1,13 @@ -

If 简单 #utils

by Pavel Glushkov @pashutk

接受挑战    English 日本語 한국어

- -实现一个 `IF` 类型,它接收一个条件类型 `C` ,一个判断为真时的返回类型 `T` ,以及一个判断为假时的返回类型 `F`。 `C` 只能是 `true` 或者 `false`, `T` 和 `F` 可以是任意类型。 - -举例: - -```ts -type A = If // expected to be 'a' -type B = If // expected to be 'b' -``` - - +

If 简单 #utils

by Pavel Glushkov @pashutk

接受挑战    English 日本語 한국어

+ +实现一个 `IF` 类型,它接收一个条件类型 `C` ,一个判断为真时的返回类型 `T` ,以及一个判断为假时的返回类型 `F`。 `C` 只能是 `true` 或者 `false`, `T` 和 `F` 可以是任意类型。 + +举例: + +```ts +type A = If // expected to be 'a' +type B = If // expected to be 'b' +``` + +
返回首页 分享你的解答 查看解答 \ No newline at end of file diff --git a/questions/268-easy-if/info.yml b/questions/00268-easy-if/info.yml similarity index 100% rename from questions/268-easy-if/info.yml rename to questions/00268-easy-if/info.yml diff --git a/questions/268-easy-if/template.ts b/questions/00268-easy-if/template.ts similarity index 100% rename from questions/268-easy-if/template.ts rename to questions/00268-easy-if/template.ts diff --git a/questions/268-easy-if/test-cases.ts b/questions/00268-easy-if/test-cases.ts similarity index 96% rename from questions/268-easy-if/test-cases.ts rename to questions/00268-easy-if/test-cases.ts index b2c673eed..351c42f77 100644 --- a/questions/268-easy-if/test-cases.ts +++ b/questions/00268-easy-if/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'a'>>, - Expect, 2>>, -] - -// @ts-expect-error +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'a'>>, + Expect, 2>>, +] + +// @ts-expect-error type error = If diff --git a/questions/270-hard-typed-get/README.ja.md b/questions/00270-hard-typed-get/README.ja.md similarity index 98% rename from questions/270-hard-typed-get/README.ja.md rename to questions/00270-hard-typed-get/README.ja.md index 55db12959..3b95cfa6b 100644 --- a/questions/270-hard-typed-get/README.ja.md +++ b/questions/00270-hard-typed-get/README.ja.md @@ -1,27 +1,27 @@ -

Typed Get 上級 #utils #template-literal

by Anthony Fu @antfu

挑戦する    English

- -[lodash の get 関数](https://lodash.com/docs/4.17.15#get)は JavaScript でネストした値にアクセスする際にとても便利です。しかし、TypeScript でこのような関数を使うと型情報が失われてしまいます。 -TypeScript4.1 の機能である[Template Literal Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types)を使うと、`get`の適切な型付けが可能となります。 -これを実装できるでしょうか? - -例えば、 - -```ts -type Data = { - foo: { - bar: { - value: 'foobar'; - count: 6; - }; - included: true; - }; - hello: 'world'; -}; -type A = Get; // 'world' -type B = Get; // 6 -type C = Get; // { value: 'foobar', count: 6 } -``` - -この課題では、配列へのアクセスは必要ありません。 - -
戻る 解答を共有 解答を確認 +

Typed Get 上級 #utils #template-literal

by Anthony Fu @antfu

挑戦する    English

+ +[lodash の get 関数](https://lodash.com/docs/4.17.15#get)は JavaScript でネストした値にアクセスする際にとても便利です。しかし、TypeScript でこのような関数を使うと型情報が失われてしまいます。 +TypeScript4.1 の機能である[Template Literal Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types)を使うと、`get`の適切な型付けが可能となります。 +これを実装できるでしょうか? + +例えば、 + +```ts +type Data = { + foo: { + bar: { + value: 'foobar'; + count: 6; + }; + included: true; + }; + hello: 'world'; +}; +type A = Get; // 'world' +type B = Get; // 6 +type C = Get; // { value: 'foobar', count: 6 } +``` + +この課題では、配列へのアクセスは必要ありません。 + +
戻る 解答を共有 解答を確認 diff --git a/questions/270-hard-typed-get/README.md b/questions/00270-hard-typed-get/README.md similarity index 99% rename from questions/270-hard-typed-get/README.md rename to questions/00270-hard-typed-get/README.md index 153059646..84bed0da2 100644 --- a/questions/270-hard-typed-get/README.md +++ b/questions/00270-hard-typed-get/README.md @@ -1,26 +1,26 @@

Typed Get hard #utils #template-literal

by Anthony Fu @antfu

Take the Challenge    日本語

-The [`get` function in lodash](https://lodash.com/docs/4.17.15#get) is a quite convenient helper for accessing nested values in JavaScript. However, when we come to TypeScript, using functions like this will make you lose the type information. With TS 4.1's upcoming [Template Literal Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types) feature, properly typing `get` becomes possible. Can you implement it? - -For example, - -```ts -type Data = { - foo: { - bar: { - value: 'foobar', - count: 6, - }, - included: true, - }, - hello: 'world' -} - -type A = Get // 'world' -type B = Get // 6 -type C = Get // { value: 'foobar', count: 6 } -``` - +The [`get` function in lodash](https://lodash.com/docs/4.17.15#get) is a quite convenient helper for accessing nested values in JavaScript. However, when we come to TypeScript, using functions like this will make you lose the type information. With TS 4.1's upcoming [Template Literal Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types) feature, properly typing `get` becomes possible. Can you implement it? + +For example, + +```ts +type Data = { + foo: { + bar: { + value: 'foobar', + count: 6, + }, + included: true, + }, + hello: 'world' +} + +type A = Get // 'world' +type B = Get // 6 +type C = Get // { value: 'foobar', count: 6 } +``` + Accessing arrays is not required in this challenge. diff --git a/questions/270-hard-typed-get/info.yml b/questions/00270-hard-typed-get/info.yml similarity index 100% rename from questions/270-hard-typed-get/info.yml rename to questions/00270-hard-typed-get/info.yml diff --git a/questions/270-hard-typed-get/template.ts b/questions/00270-hard-typed-get/template.ts similarity index 100% rename from questions/270-hard-typed-get/template.ts rename to questions/00270-hard-typed-get/template.ts diff --git a/questions/270-hard-typed-get/test-cases.ts b/questions/00270-hard-typed-get/test-cases.ts similarity index 95% rename from questions/270-hard-typed-get/test-cases.ts rename to questions/00270-hard-typed-get/test-cases.ts index 18de8457b..6acf88675 100644 --- a/questions/270-hard-typed-get/test-cases.ts +++ b/questions/00270-hard-typed-get/test-cases.ts @@ -1,20 +1,20 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'world'>>, - Expect, 6>>, - Expect, { value: 'foobar'; count: 6 }>>, - - Expect, never>>, -] - -type Data = { - foo: { - bar: { - value: 'foobar' - count: 6 - } - included: true - } - hello: 'world' +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'world'>>, + Expect, 6>>, + Expect, { value: 'foobar'; count: 6 }>>, + + Expect, never>>, +] + +type Data = { + foo: { + bar: { + value: 'foobar' + count: 6 + } + included: true + } + hello: 'world' } diff --git a/questions/274-extreme-integers-comparator/README.md b/questions/00274-extreme-integers-comparator/README.md similarity index 99% rename from questions/274-extreme-integers-comparator/README.md rename to questions/00274-extreme-integers-comparator/README.md index 1dcc298b8..da794d9a8 100644 --- a/questions/274-extreme-integers-comparator/README.md +++ b/questions/00274-extreme-integers-comparator/README.md @@ -1,11 +1,11 @@

Integers Comparator extreme #template-literal #math

by Pig Fang @g-plane

Take the Challenge

-Implement a type-level integers comparator. We've provided an enum for indicating the comparison result, like this: - -- If `a` is greater than `b`, type should be `Comparison.Greater`. -- If `a` and `b` are equal, type should be `Comparison.Equal`. -- If `a` is lower than `b`, type should be `Comparison.Lower`. - +Implement a type-level integers comparator. We've provided an enum for indicating the comparison result, like this: + +- If `a` is greater than `b`, type should be `Comparison.Greater`. +- If `a` and `b` are equal, type should be `Comparison.Equal`. +- If `a` is lower than `b`, type should be `Comparison.Lower`. + **Note that `a` and `b` can be positive integers or negative integers or zero, even one is positive while another one is negative.** diff --git a/questions/274-extreme-integers-comparator/info.yml b/questions/00274-extreme-integers-comparator/info.yml similarity index 100% rename from questions/274-extreme-integers-comparator/info.yml rename to questions/00274-extreme-integers-comparator/info.yml diff --git a/questions/274-extreme-integers-comparator/template.ts b/questions/00274-extreme-integers-comparator/template.ts similarity index 94% rename from questions/274-extreme-integers-comparator/template.ts rename to questions/00274-extreme-integers-comparator/template.ts index 087243307..ee8646a17 100644 --- a/questions/274-extreme-integers-comparator/template.ts +++ b/questions/00274-extreme-integers-comparator/template.ts @@ -1,7 +1,7 @@ -enum Comparison { - Greater, - Equal, - Lower, -} - +enum Comparison { + Greater, + Equal, + Lower, +} + type Comparator = any diff --git a/questions/274-extreme-integers-comparator/test-cases.ts b/questions/00274-extreme-integers-comparator/test-cases.ts similarity index 98% rename from questions/274-extreme-integers-comparator/test-cases.ts rename to questions/00274-extreme-integers-comparator/test-cases.ts index ef122500b..c470cf129 100644 --- a/questions/274-extreme-integers-comparator/test-cases.ts +++ b/questions/00274-extreme-integers-comparator/test-cases.ts @@ -1,21 +1,21 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, Comparison.Equal>>, - Expect, Comparison.Lower>>, - Expect, Comparison.Lower>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Lower>>, - Expect, Comparison.Equal>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Lower>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Greater>>, - Expect, Comparison.Lower>>, - Expect, Comparison.Equal>>, - Expect, Comparison.Equal>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, Comparison.Equal>>, + Expect, Comparison.Lower>>, + Expect, Comparison.Lower>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Lower>>, + Expect, Comparison.Equal>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Lower>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Greater>>, + Expect, Comparison.Lower>>, + Expect, Comparison.Equal>>, + Expect, Comparison.Equal>>, ] diff --git a/questions/296-medium-permutation/README.ja.md b/questions/00296-medium-permutation/README.ja.md similarity index 100% rename from questions/296-medium-permutation/README.ja.md rename to questions/00296-medium-permutation/README.ja.md diff --git a/questions/296-medium-permutation/README.md b/questions/00296-medium-permutation/README.md similarity index 100% rename from questions/296-medium-permutation/README.md rename to questions/00296-medium-permutation/README.md diff --git a/questions/296-medium-permutation/README.zh-CN.md b/questions/00296-medium-permutation/README.zh-CN.md similarity index 100% rename from questions/296-medium-permutation/README.zh-CN.md rename to questions/00296-medium-permutation/README.zh-CN.md diff --git a/questions/296-medium-permutation/info.yml b/questions/00296-medium-permutation/info.yml similarity index 100% rename from questions/296-medium-permutation/info.yml rename to questions/00296-medium-permutation/info.yml diff --git a/questions/296-medium-permutation/template.ts b/questions/00296-medium-permutation/template.ts similarity index 100% rename from questions/296-medium-permutation/template.ts rename to questions/00296-medium-permutation/template.ts diff --git a/questions/296-medium-permutation/test-cases.ts b/questions/00296-medium-permutation/test-cases.ts similarity index 98% rename from questions/296-medium-permutation/test-cases.ts rename to questions/00296-medium-permutation/test-cases.ts index eef7fa5d5..8af3291b0 100644 --- a/questions/296-medium-permutation/test-cases.ts +++ b/questions/00296-medium-permutation/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, ['A']>>, - Expect, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, - Expect, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, - Expect, []>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, ['A']>>, + Expect, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, + Expect, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, + Expect, []>>, ] diff --git a/questions/298-medium-length-of-string/README.ja.md b/questions/00298-medium-length-of-string/README.ja.md similarity index 100% rename from questions/298-medium-length-of-string/README.ja.md rename to questions/00298-medium-length-of-string/README.ja.md diff --git a/questions/298-medium-length-of-string/README.md b/questions/00298-medium-length-of-string/README.md similarity index 100% rename from questions/298-medium-length-of-string/README.md rename to questions/00298-medium-length-of-string/README.md diff --git a/questions/298-medium-length-of-string/info.yml b/questions/00298-medium-length-of-string/info.yml similarity index 100% rename from questions/298-medium-length-of-string/info.yml rename to questions/00298-medium-length-of-string/info.yml diff --git a/questions/298-medium-length-of-string/template.ts b/questions/00298-medium-length-of-string/template.ts similarity index 100% rename from questions/298-medium-length-of-string/template.ts rename to questions/00298-medium-length-of-string/template.ts diff --git a/questions/298-medium-length-of-string/test-cases.ts b/questions/00298-medium-length-of-string/test-cases.ts similarity index 97% rename from questions/298-medium-length-of-string/test-cases.ts rename to questions/00298-medium-length-of-string/test-cases.ts index ace9dd383..c60b2d773 100644 --- a/questions/298-medium-length-of-string/test-cases.ts +++ b/questions/00298-medium-length-of-string/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 0>>, - Expect, 6>>, - Expect, 5>>, - Expect, 16>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 0>>, + Expect, 6>>, + Expect, 5>>, + Expect, 16>>, ] diff --git a/questions/300-hard-string-to-number/README.ja.md b/questions/00300-hard-string-to-number/README.ja.md similarity index 100% rename from questions/300-hard-string-to-number/README.ja.md rename to questions/00300-hard-string-to-number/README.ja.md diff --git a/questions/300-hard-string-to-number/README.md b/questions/00300-hard-string-to-number/README.md similarity index 100% rename from questions/300-hard-string-to-number/README.md rename to questions/00300-hard-string-to-number/README.md diff --git a/questions/300-hard-string-to-number/info.yml b/questions/00300-hard-string-to-number/info.yml similarity index 100% rename from questions/300-hard-string-to-number/info.yml rename to questions/00300-hard-string-to-number/info.yml diff --git a/questions/300-hard-string-to-number/template.ts b/questions/00300-hard-string-to-number/template.ts similarity index 100% rename from questions/300-hard-string-to-number/template.ts rename to questions/00300-hard-string-to-number/template.ts diff --git a/questions/300-hard-string-to-number/test-cases.ts b/questions/00300-hard-string-to-number/test-cases.ts similarity index 96% rename from questions/300-hard-string-to-number/test-cases.ts rename to questions/00300-hard-string-to-number/test-cases.ts index ede24cff6..5136a81eb 100644 --- a/questions/300-hard-string-to-number/test-cases.ts +++ b/questions/00300-hard-string-to-number/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 0>>, - Expect, 5>>, - Expect, 12>>, - Expect, 27>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 0>>, + Expect, 5>>, + Expect, 12>>, + Expect, 27>>, ] diff --git a/questions/399-hard-tuple-filter/README.ja.md b/questions/00399-hard-tuple-filter/README.ja.md similarity index 100% rename from questions/399-hard-tuple-filter/README.ja.md rename to questions/00399-hard-tuple-filter/README.ja.md diff --git a/questions/399-hard-tuple-filter/README.md b/questions/00399-hard-tuple-filter/README.md similarity index 99% rename from questions/399-hard-tuple-filter/README.md rename to questions/00399-hard-tuple-filter/README.md index a8e218022..69e4097ff 100644 --- a/questions/399-hard-tuple-filter/README.md +++ b/questions/00399-hard-tuple-filter/README.md @@ -1,10 +1,10 @@

Tuple Filter hard #tuple #infer

by Ryo Hanafusa @softoika

Take the Challenge    日本語

-Implement a type `FilterOut` that filters out items of the given type `F` from the tuple `T`. - -For example, -```ts -type Filtered = FilterOut<[1, 2, null, 3], null> // [1, 2, 3] +Implement a type `FilterOut` that filters out items of the given type `F` from the tuple `T`. + +For example, +```ts +type Filtered = FilterOut<[1, 2, null, 3], null> // [1, 2, 3] ``` diff --git a/questions/399-hard-tuple-filter/info.yml b/questions/00399-hard-tuple-filter/info.yml similarity index 100% rename from questions/399-hard-tuple-filter/info.yml rename to questions/00399-hard-tuple-filter/info.yml diff --git a/questions/399-hard-tuple-filter/template.ts b/questions/00399-hard-tuple-filter/template.ts similarity index 100% rename from questions/399-hard-tuple-filter/template.ts rename to questions/00399-hard-tuple-filter/template.ts diff --git a/questions/399-hard-tuple-filter/test-cases.ts b/questions/00399-hard-tuple-filter/test-cases.ts similarity index 98% rename from questions/399-hard-tuple-filter/test-cases.ts rename to questions/00399-hard-tuple-filter/test-cases.ts index 85fd4d69f..2684b396f 100644 --- a/questions/399-hard-tuple-filter/test-cases.ts +++ b/questions/00399-hard-tuple-filter/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, []>>, - Expect, ['a']>>, - Expect, [1, 'a']>>, - Expect, [1, 'a', false]>>, - Expect, [number | null | undefined]>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, []>>, + Expect, ['a']>>, + Expect, [1, 'a']>>, + Expect, [1, 'a', false]>>, + Expect, [number | null | undefined]>>, +] diff --git a/questions/459-medium-flatten/README.ja.md b/questions/00459-medium-flatten/README.ja.md similarity index 99% rename from questions/459-medium-flatten/README.ja.md rename to questions/00459-medium-flatten/README.ja.md index f2924ad37..859987eaa 100644 --- a/questions/459-medium-flatten/README.ja.md +++ b/questions/00459-medium-flatten/README.ja.md @@ -1,11 +1,11 @@ -

Flatten 中級 #array

by zhouyiming @chbro

挑戦する    English 简体中文

- -この課題では、受け取った配列をフラット化した型を出力する型を書く必要があります。 - -例えば: - -```ts -type flatten = Flatten<[1, 2, [3, 4], [[[5]]]> // [1, 2, 3, 4, 5] -``` - -
戻る 解答を共有 解答を確認 +

Flatten 中級 #array

by zhouyiming @chbro

挑戦する    English 简体中文

+ +この課題では、受け取った配列をフラット化した型を出力する型を書く必要があります。 + +例えば: + +```ts +type flatten = Flatten<[1, 2, [3, 4], [[[5]]]> // [1, 2, 3, 4, 5] +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/459-medium-flatten/README.md b/questions/00459-medium-flatten/README.md similarity index 99% rename from questions/459-medium-flatten/README.md rename to questions/00459-medium-flatten/README.md index ceffc47fe..5578679f4 100644 --- a/questions/459-medium-flatten/README.md +++ b/questions/00459-medium-flatten/README.md @@ -1,12 +1,12 @@ -

Flatten medium #array

by zhouyiming @chbro

Take the Challenge    简体中文 日本語

- -In this challenge, you would need to write a type that takes an array and emitted the flatten array type. - -For example: - -```ts -type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] -``` - - -
Back Share your Solutions Check out Solutions +

Flatten medium #array

by zhouyiming @chbro

Take the Challenge    简体中文 日本語

+ +In this challenge, you would need to write a type that takes an array and emitted the flatten array type. + +For example: + +```ts +type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/459-medium-flatten/README.zh-CN.md b/questions/00459-medium-flatten/README.zh-CN.md similarity index 99% rename from questions/459-medium-flatten/README.zh-CN.md rename to questions/00459-medium-flatten/README.zh-CN.md index 34dc07210..49e59eab7 100644 --- a/questions/459-medium-flatten/README.zh-CN.md +++ b/questions/00459-medium-flatten/README.zh-CN.md @@ -1,12 +1,12 @@ -

Flatten 中等 #array

by zhouyiming @chbro

接受挑战    English 日本語

- -在这个挑战中,你需要写一个接受数组的类型,并且返回扁平化的数组类型。 - -例如: - -```ts -type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] -``` - - -
返回首页 分享你的解答 查看解答 +

Flatten 中等 #array

by zhouyiming @chbro

接受挑战    English 日本語

+ +在这个挑战中,你需要写一个接受数组的类型,并且返回扁平化的数组类型。 + +例如: + +```ts +type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] +``` + + +
返回首页 分享你的解答 查看解答 diff --git a/questions/459-medium-flatten/info.yml b/questions/00459-medium-flatten/info.yml similarity index 100% rename from questions/459-medium-flatten/info.yml rename to questions/00459-medium-flatten/info.yml diff --git a/questions/459-medium-flatten/template.ts b/questions/00459-medium-flatten/template.ts similarity index 100% rename from questions/459-medium-flatten/template.ts rename to questions/00459-medium-flatten/template.ts diff --git a/questions/459-medium-flatten/test-cases.ts b/questions/00459-medium-flatten/test-cases.ts similarity index 97% rename from questions/459-medium-flatten/test-cases.ts rename to questions/00459-medium-flatten/test-cases.ts index efaee650c..3935c22b8 100644 --- a/questions/459-medium-flatten/test-cases.ts +++ b/questions/00459-medium-flatten/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [1, 2, 3, 4]>>, - Expect, [1, 2]>>, - Expect, [1, 2, 3, 4, 5]>>, - Expect, [{ foo: 'bar'; 2: 10 }, 'foobar']>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [1, 2, 3, 4]>>, + Expect, [1, 2]>>, + Expect, [1, 2, 3, 4, 5]>>, + Expect, [{ foo: 'bar'; 2: 10 }, 'foobar']>>, +] diff --git a/questions/462-extreme-currying-2/README.md b/questions/00462-extreme-currying-2/README.md similarity index 90% rename from questions/462-extreme-currying-2/README.md rename to questions/00462-extreme-currying-2/README.md index 5b5dbab85..6b2337d36 100644 --- a/questions/462-extreme-currying-2/README.md +++ b/questions/00462-extreme-currying-2/README.md @@ -1,32 +1,32 @@ -

Currying 2 extreme

by Kim @hubvue

Take the Challenge    简体中文

- -[Currying](https://en.wikipedia.org/wiki/Currying) is the technique of converting a function that takes multiple arguments into a sequence of functions that each take a single argument. - -But in our daily life, currying dynamic arguments is also commonly used, for example, the `Function.bind(this, [...params])` API. - -```ts -const func = (a: number, b: number, c: number) => { - return a + b + c -} - -const bindFunc = func(null, 1, 2) - -const result = bindFunc(3) // result: 6 -``` - -Thus, based on `Currying 1`, we would need to have the dynamic argument version: - -```ts -const add = (a: number, b: number, c: number) => a + b + c -const three = add(1, 1, 1) - -const curriedAdd = DynamicParamsCurrying(add) -const six = curriedAdd(1, 2, 3) -const seven = curriedAdd(1, 2)(4) -const eight = curriedAdd(2)(3)(4) -``` - -In this challenge, `DynamicParamsCurrying` may take a function with zero to multiple arguments, you need to correctly type it. The returned function may accept at least one argument. When all the arguments as satisfied, it should yield the return type of the original function correctly. - - -
Back Share your Solutions Check out Solutions

Related Challenges

17・Currying 1 +

Currying 2 extreme

by Kim @hubvue

Take the Challenge    简体中文

+ +[Currying](https://en.wikipedia.org/wiki/Currying) is the technique of converting a function that takes multiple arguments into a sequence of functions that each take a single argument. + +But in our daily life, currying dynamic arguments is also commonly used, for example, the `Function.bind(this, [...params])` API. + +```ts +const func = (a: number, b: number, c: number) => { + return a + b + c +} + +const bindFunc = func(null, 1, 2) + +const result = bindFunc(3) // result: 6 +``` + +Thus, based on `Currying 1`, we would need to have the dynamic argument version: + +```ts +const add = (a: number, b: number, c: number) => a + b + c +const three = add(1, 1, 1) + +const curriedAdd = DynamicParamsCurrying(add) +const six = curriedAdd(1, 2, 3) +const seven = curriedAdd(1, 2)(4) +const eight = curriedAdd(2)(3)(4) +``` + +In this challenge, `DynamicParamsCurrying` may take a function with zero to multiple arguments, you need to correctly type it. The returned function may accept at least one argument. When all the arguments as satisfied, it should yield the return type of the original function correctly. + + +
Back Share your Solutions Check out Solutions

Related Challenges

17・Currying 1 diff --git a/questions/462-extreme-currying-2/README.zh-CN.md b/questions/00462-extreme-currying-2/README.zh-CN.md similarity index 89% rename from questions/462-extreme-currying-2/README.zh-CN.md rename to questions/00462-extreme-currying-2/README.zh-CN.md index ee3e205ef..390de252d 100644 --- a/questions/462-extreme-currying-2/README.zh-CN.md +++ b/questions/00462-extreme-currying-2/README.zh-CN.md @@ -1,34 +1,34 @@ -

柯里化 2 地狱

by Kim @hubvue

接受挑战    English

- -[Currying](https://en.wikipedia.org/wiki/Currying) 是一种将带有多个参数的函数转换为每个带有一个参数的函数序列的技术。 - -但是在前端的日常开发中,柯里化函数参数个数动态化却是非常常见的,例如 `Function.bind(this, [...params])` - -```ts -const func = (a: number, b: number, c: number) => { - return a + b + c -} - -const bindFunc = func(null, 1, 2) - -const result = bindFunc(3) // result: 6 -``` - -因此,在 `柯里化` 的基础上,我们更需要的是 `动态参数化的柯里化函数` - -```ts -const add = (a: number, b: number, c: number) => a + b + c -const three = add(1, 1, 1) - -const curriedAdd = DynamicParamsCurrying(add) -const six = curriedAdd(1, 2, 3) -const seven = curriedAdd(1, 2)(4) -const eight = curriedAdd(2)(3)(4) -``` - -传递给 `DynamicParamsCurrying` 的函数可能有多个参数,您需要实现它的类型。 - -在此挑战中,curriedAdd函数每次可接受最少一个参数,但是所有参数个数总和及类型与原函数相同。分配完所有参数后,它应返回其结果。 - - -
返回首页 分享你的解答 查看解答

相关挑战

17・柯里化 1 +

柯里化 2 地狱

by Kim @hubvue

接受挑战    English

+ +[Currying](https://en.wikipedia.org/wiki/Currying) 是一种将带有多个参数的函数转换为每个带有一个参数的函数序列的技术。 + +但是在前端的日常开发中,柯里化函数参数个数动态化却是非常常见的,例如 `Function.bind(this, [...params])` + +```ts +const func = (a: number, b: number, c: number) => { + return a + b + c +} + +const bindFunc = func(null, 1, 2) + +const result = bindFunc(3) // result: 6 +``` + +因此,在 `柯里化` 的基础上,我们更需要的是 `动态参数化的柯里化函数` + +```ts +const add = (a: number, b: number, c: number) => a + b + c +const three = add(1, 1, 1) + +const curriedAdd = DynamicParamsCurrying(add) +const six = curriedAdd(1, 2, 3) +const seven = curriedAdd(1, 2)(4) +const eight = curriedAdd(2)(3)(4) +``` + +传递给 `DynamicParamsCurrying` 的函数可能有多个参数,您需要实现它的类型。 + +在此挑战中,curriedAdd函数每次可接受最少一个参数,但是所有参数个数总和及类型与原函数相同。分配完所有参数后,它应返回其结果。 + + +
返回首页 分享你的解答 查看解答

相关挑战

17・柯里化 1 diff --git a/questions/462-extreme-currying-2/info.yml b/questions/00462-extreme-currying-2/info.yml similarity index 100% rename from questions/462-extreme-currying-2/info.yml rename to questions/00462-extreme-currying-2/info.yml diff --git a/questions/462-extreme-currying-2/info.zh-CN.yml b/questions/00462-extreme-currying-2/info.zh-CN.yml similarity index 100% rename from questions/462-extreme-currying-2/info.zh-CN.yml rename to questions/00462-extreme-currying-2/info.zh-CN.yml diff --git a/questions/462-extreme-currying-2/template.ts b/questions/00462-extreme-currying-2/template.ts similarity index 100% rename from questions/462-extreme-currying-2/template.ts rename to questions/00462-extreme-currying-2/template.ts diff --git a/questions/462-extreme-currying-2/test-cases.ts b/questions/00462-extreme-currying-2/test-cases.ts similarity index 98% rename from questions/462-extreme-currying-2/test-cases.ts rename to questions/00462-extreme-currying-2/test-cases.ts index a75ee123d..448f33b4b 100644 --- a/questions/462-extreme-currying-2/test-cases.ts +++ b/questions/00462-extreme-currying-2/test-cases.ts @@ -1,36 +1,36 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -const curried1 = DynamicParamsCurrying((a: string, b: number, c: boolean) => true) -const curried2 = DynamicParamsCurrying((a: string, b: number, c: boolean, d: boolean, e: boolean, f: string, g: boolean) => true) - -const curried1Return1 = curried1('123')(123)(true) -const curried1Return2 = curried1('123', 123)(false) -const curried1Return3 = curried1('123', 123, true) - -const curried2Return1 = curried2('123')(123)(true)(false)(true)('123')(false) -const curried2Return2 = curried2('123', 123)(true, false)(true, '123')(false) -const curried2Return3 = curried2('123', 123)(true)(false)(true, '123', false) -const curried2Return4 = curried2('123', 123, true)(false, true, '123')(false) -const curried2Return5 = curried2('123', 123, true)(false)(true)('123')(false) -const curried2Return6 = curried2('123', 123, true, false)(true, '123', false) -const curried2Return7 = curried2('123', 123, true, false, true)('123', false) -const curried2Return8 = curried2('123', 123, true, false, true)('123')(false) -const curried2Return9 = curried2('123', 123, true, false, true, '123')(false) -const curried2Return10 = curried2('123', 123, true, false, true, '123', false) - -type cases = [ - Expect>, - Expect>, - Expect>, - - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +const curried1 = DynamicParamsCurrying((a: string, b: number, c: boolean) => true) +const curried2 = DynamicParamsCurrying((a: string, b: number, c: boolean, d: boolean, e: boolean, f: string, g: boolean) => true) + +const curried1Return1 = curried1('123')(123)(true) +const curried1Return2 = curried1('123', 123)(false) +const curried1Return3 = curried1('123', 123, true) + +const curried2Return1 = curried2('123')(123)(true)(false)(true)('123')(false) +const curried2Return2 = curried2('123', 123)(true, false)(true, '123')(false) +const curried2Return3 = curried2('123', 123)(true)(false)(true, '123', false) +const curried2Return4 = curried2('123', 123, true)(false, true, '123')(false) +const curried2Return5 = curried2('123', 123, true)(false)(true)('123')(false) +const curried2Return6 = curried2('123', 123, true, false)(true, '123', false) +const curried2Return7 = curried2('123', 123, true, false, true)('123', false) +const curried2Return8 = curried2('123', 123, true, false, true)('123')(false) +const curried2Return9 = curried2('123', 123, true, false, true, '123')(false) +const curried2Return10 = curried2('123', 123, true, false, true, '123', false) + +type cases = [ + Expect>, + Expect>, + Expect>, + + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, +] diff --git a/questions/472-hard-tuple-to-enum-object/README.ja.md b/questions/00472-hard-tuple-to-enum-object/README.ja.md similarity index 70% rename from questions/472-hard-tuple-to-enum-object/README.ja.md rename to questions/00472-hard-tuple-to-enum-object/README.ja.md index 6de0777e9..47283b2fe 100644 --- a/questions/472-hard-tuple-to-enum-object/README.ja.md +++ b/questions/00472-hard-tuple-to-enum-object/README.ja.md @@ -1,29 +1,29 @@ -

Tuple to Enum Object 上級 #tuple #template-literal

by Ryo Hanafusa @softoika

挑戦する    English

- -enum は TypeScript 独自の文法です(JavaScript にはありません)。そのため、以下の形式にトランスパイルされます。 - -```js -let OperatingSystem; -(function (OperatingSystem) { - OperatingSystem[(OperatingSystem['MacOS'] = 0)] = 'MacOS'; - OperatingSystem[(OperatingSystem['Windows'] = 1)] = 'Windows'; - OperatingSystem[(OperatingSystem['Linux'] = 2)] = 'Linux'; -})(OperatingSystem || (OperatingSystem = {})); -``` - -この問題では、文字列のタプルを enum と同じようなオブジェクトに変換する型を実装します。 -さらに、enum のプロパティはパスカルケースであることが好ましいです。 - -```ts -Enum<["macOS", "Windows", "Linux"]> -// -> { readonly MacOS: "macOS", readonly Windows: "Windows", readonly Linux: "Linux" } -``` - -第 2 引数に`true`が与えられた場合、値は数値リテラルとなります。 - -```ts -Enum<["macOS", "Windows", "Linux"], true> -// -> { readonly MacOS: 0, readonly Windows: 1, readonly Linux: 2 } -``` - -
戻る 解答を共有 解答を確認

関連する課題

10・Tuple to Union 11・Tuple to Object 730・Union to Tuple 3188・Tuple to Nested Object +

Tuple to Enum Object 上級 #tuple #template-literal

by Ryo Hanafusa @softoika

挑戦する    English

+ +enum は TypeScript 独自の文法です(JavaScript にはありません)。そのため、以下の形式にトランスパイルされます。 + +```js +let OperatingSystem; +(function (OperatingSystem) { + OperatingSystem[(OperatingSystem['MacOS'] = 0)] = 'MacOS'; + OperatingSystem[(OperatingSystem['Windows'] = 1)] = 'Windows'; + OperatingSystem[(OperatingSystem['Linux'] = 2)] = 'Linux'; +})(OperatingSystem || (OperatingSystem = {})); +``` + +この問題では、文字列のタプルを enum と同じようなオブジェクトに変換する型を実装します。 +さらに、enum のプロパティはパスカルケースであることが好ましいです。 + +```ts +Enum<["macOS", "Windows", "Linux"]> +// -> { readonly MacOS: "macOS", readonly Windows: "Windows", readonly Linux: "Linux" } +``` + +第 2 引数に`true`が与えられた場合、値は数値リテラルとなります。 + +```ts +Enum<["macOS", "Windows", "Linux"], true> +// -> { readonly MacOS: 0, readonly Windows: 1, readonly Linux: 2 } +``` + +
戻る 解答を共有 解答を確認

関連する課題

10・Tuple to Union 11・Tuple to Object 730・Union to Tuple 3188・Tuple to Nested Object diff --git a/questions/472-hard-tuple-to-enum-object/README.md b/questions/00472-hard-tuple-to-enum-object/README.md similarity index 69% rename from questions/472-hard-tuple-to-enum-object/README.md rename to questions/00472-hard-tuple-to-enum-object/README.md index d3f4674c1..ec2b4ee24 100644 --- a/questions/472-hard-tuple-to-enum-object/README.md +++ b/questions/00472-hard-tuple-to-enum-object/README.md @@ -1,25 +1,25 @@

Tuple to Enum Object hard #tuple #template-literal

by Ryo Hanafusa @softoika

Take the Challenge    日本語

-The enum is an original syntax of TypeScript (it does not exist in JavaScript). So it is converted to like the following form as a result of transpilation: -```js -let OperatingSystem; -(function (OperatingSystem) { - OperatingSystem[OperatingSystem["MacOS"] = 0] = "MacOS"; - OperatingSystem[OperatingSystem["Windows"] = 1] = "Windows"; - OperatingSystem[OperatingSystem["Linux"] = 2] = "Linux"; -})(OperatingSystem || (OperatingSystem = {})); -``` -In this question, the type should convert a given string tuple to an object that behaves like an enum. -Moreover, the property of an enum is preferably a pascal case. -```ts -Enum<["macOS", "Windows", "Linux"]> -// -> { readonly MacOS: "macOS", readonly Windows: "Windows", readonly Linux: "Linux" } -``` -If `true` is given in the second argument, the value should be a number literal. -```ts -Enum<["macOS", "Windows", "Linux"], true> -// -> { readonly MacOS: 0, readonly Windows: 1, readonly Linux: 2 } +The enum is an original syntax of TypeScript (it does not exist in JavaScript). So it is converted to like the following form as a result of transpilation: +```js +let OperatingSystem; +(function (OperatingSystem) { + OperatingSystem[OperatingSystem["MacOS"] = 0] = "MacOS"; + OperatingSystem[OperatingSystem["Windows"] = 1] = "Windows"; + OperatingSystem[OperatingSystem["Linux"] = 2] = "Linux"; +})(OperatingSystem || (OperatingSystem = {})); +``` +In this question, the type should convert a given string tuple to an object that behaves like an enum. +Moreover, the property of an enum is preferably a pascal case. +```ts +Enum<["macOS", "Windows", "Linux"]> +// -> { readonly MacOS: "macOS", readonly Windows: "Windows", readonly Linux: "Linux" } +``` +If `true` is given in the second argument, the value should be a number literal. +```ts +Enum<["macOS", "Windows", "Linux"], true> +// -> { readonly MacOS: 0, readonly Windows: 1, readonly Linux: 2 } ``` -
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 730・Union to Tuple 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/472-hard-tuple-to-enum-object/info.yml b/questions/00472-hard-tuple-to-enum-object/info.yml similarity index 100% rename from questions/472-hard-tuple-to-enum-object/info.yml rename to questions/00472-hard-tuple-to-enum-object/info.yml diff --git a/questions/472-hard-tuple-to-enum-object/template.ts b/questions/00472-hard-tuple-to-enum-object/template.ts similarity index 100% rename from questions/472-hard-tuple-to-enum-object/template.ts rename to questions/00472-hard-tuple-to-enum-object/template.ts diff --git a/questions/472-hard-tuple-to-enum-object/test-cases.ts b/questions/00472-hard-tuple-to-enum-object/test-cases.ts similarity index 95% rename from questions/472-hard-tuple-to-enum-object/test-cases.ts rename to questions/00472-hard-tuple-to-enum-object/test-cases.ts index bee5a3dcc..be5c5d313 100644 --- a/questions/472-hard-tuple-to-enum-object/test-cases.ts +++ b/questions/00472-hard-tuple-to-enum-object/test-cases.ts @@ -1,54 +1,54 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -const OperatingSystem = ['macOS', 'Windows', 'Linux'] as const -const Command = ['echo', 'grep', 'sed', 'awk', 'cut', 'uniq', 'head', 'tail', 'xargs', 'shift'] as const - -type cases = [ - Expect, {}>>, - Expect, - { - readonly MacOS: 'macOS' - readonly Windows: 'Windows' - readonly Linux: 'Linux' - } - >>, - Expect, - { - readonly MacOS: 0 - readonly Windows: 1 - readonly Linux: 2 - } - >>, - Expect, - { - readonly Echo: 'echo' - readonly Grep: 'grep' - readonly Sed: 'sed' - readonly Awk: 'awk' - readonly Cut: 'cut' - readonly Uniq: 'uniq' - readonly Head: 'head' - readonly Tail: 'tail' - readonly Xargs: 'xargs' - readonly Shift: 'shift' - } - >>, - Expect, - { - readonly Echo: 0 - readonly Grep: 1 - readonly Sed: 2 - readonly Awk: 3 - readonly Cut: 4 - readonly Uniq: 5 - readonly Head: 6 - readonly Tail: 7 - readonly Xargs: 8 - readonly Shift: 9 - } - >>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +const OperatingSystem = ['macOS', 'Windows', 'Linux'] as const +const Command = ['echo', 'grep', 'sed', 'awk', 'cut', 'uniq', 'head', 'tail', 'xargs', 'shift'] as const + +type cases = [ + Expect, {}>>, + Expect, + { + readonly MacOS: 'macOS' + readonly Windows: 'Windows' + readonly Linux: 'Linux' + } + >>, + Expect, + { + readonly MacOS: 0 + readonly Windows: 1 + readonly Linux: 2 + } + >>, + Expect, + { + readonly Echo: 'echo' + readonly Grep: 'grep' + readonly Sed: 'sed' + readonly Awk: 'awk' + readonly Cut: 'cut' + readonly Uniq: 'uniq' + readonly Head: 'head' + readonly Tail: 'tail' + readonly Xargs: 'xargs' + readonly Shift: 'shift' + } + >>, + Expect, + { + readonly Echo: 0 + readonly Grep: 1 + readonly Sed: 2 + readonly Awk: 3 + readonly Cut: 4 + readonly Uniq: 5 + readonly Head: 6 + readonly Tail: 7 + readonly Xargs: 8 + readonly Shift: 9 + } + >>, +] diff --git a/questions/476-extreme-sum/README.md b/questions/00476-extreme-sum/README.md similarity index 99% rename from questions/476-extreme-sum/README.md rename to questions/00476-extreme-sum/README.md index 4d166b01f..ca17d5e74 100644 --- a/questions/476-extreme-sum/README.md +++ b/questions/00476-extreme-sum/README.md @@ -1,14 +1,14 @@

Sum extreme #math #template-literal

by null @uid11

Take the Challenge

-Implement a type `Sum` that summing two non-negative integers and returns the sum as a string. Numbers can be specified as a string, number, or bigint. - -For example, - -```ts -type T0 = Sum<2, 3> // '5' -type T1 = Sum<'13', '21'> // '34' -type T2 = Sum<'328', 7> // '335' -type T3 = Sum<1_000_000_000_000n, '123'> // '1000000000123' +Implement a type `Sum` that summing two non-negative integers and returns the sum as a string. Numbers can be specified as a string, number, or bigint. + +For example, + +```ts +type T0 = Sum<2, 3> // '5' +type T1 = Sum<'13', '21'> // '34' +type T2 = Sum<'328', 7> // '335' +type T3 = Sum<1_000_000_000_000n, '123'> // '1000000000123' ``` diff --git a/questions/476-extreme-sum/info.yml b/questions/00476-extreme-sum/info.yml similarity index 100% rename from questions/476-extreme-sum/info.yml rename to questions/00476-extreme-sum/info.yml diff --git a/questions/476-extreme-sum/template.ts b/questions/00476-extreme-sum/template.ts similarity index 100% rename from questions/476-extreme-sum/template.ts rename to questions/00476-extreme-sum/template.ts diff --git a/questions/476-extreme-sum/test-cases.ts b/questions/00476-extreme-sum/test-cases.ts similarity index 97% rename from questions/476-extreme-sum/test-cases.ts rename to questions/00476-extreme-sum/test-cases.ts index a30255d3f..c2cb2dfc3 100644 --- a/questions/476-extreme-sum/test-cases.ts +++ b/questions/00476-extreme-sum/test-cases.ts @@ -1,13 +1,13 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, '5'>>, - Expect, '34'>>, - Expect, '335'>>, - Expect, '1000000000123'>>, - Expect, '10000'>>, - Expect, '4364766'>>, - Expect, '728'>>, - Expect, '213'>>, - Expect, '0'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, '5'>>, + Expect, '34'>>, + Expect, '335'>>, + Expect, '1000000000123'>>, + Expect, '10000'>>, + Expect, '4364766'>>, + Expect, '728'>>, + Expect, '213'>>, + Expect, '0'>>, +] diff --git a/questions/517-extreme-multiply/README.md b/questions/00517-extreme-multiply/README.md similarity index 89% rename from questions/517-extreme-multiply/README.md rename to questions/00517-extreme-multiply/README.md index 18062148f..f9a61a27e 100644 --- a/questions/517-extreme-multiply/README.md +++ b/questions/00517-extreme-multiply/README.md @@ -1,19 +1,19 @@

Multiply extreme #math #template-literal

by null @uid11

Take the Challenge

-**This challenge continues from [476 - Sum](https://tsch.js.org/476), it is recommended that you finish that one first, and modify your code based on it to start this challenge.** - -Implement a type `Multiply` that multiplies two non-negative integers and returns their product as a string. Numbers can be specified as string, number, or bigint. - -For example, - -```ts -type T0 = Multiply<2, 3> // '6' -type T1 = Multiply<3, '5'> // '15' -type T2 = Multiply<'4', 10> // '40' -type T3 = Multiply<0, 16> // '0' -type T4 = Multiply<'13', '21'> // '273' -type T5 = Multiply<'43423', 321543n> // '13962361689' +**This challenge continues from [476 - Sum](https://tsch.js.org/476), it is recommended that you finish that one first, and modify your code based on it to start this challenge.** + +Implement a type `Multiply` that multiplies two non-negative integers and returns their product as a string. Numbers can be specified as string, number, or bigint. + +For example, + +```ts +type T0 = Multiply<2, 3> // '6' +type T1 = Multiply<3, '5'> // '15' +type T2 = Multiply<'4', 10> // '40' +type T3 = Multiply<0, 16> // '0' +type T4 = Multiply<'13', '21'> // '273' +type T5 = Multiply<'43423', 321543n> // '13962361689' ``` -
Back Share your Solutions Check out Solutions

Related Challenges

476・Sum \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

476・Sum \ No newline at end of file diff --git a/questions/517-extreme-multiply/info.yml b/questions/00517-extreme-multiply/info.yml similarity index 100% rename from questions/517-extreme-multiply/info.yml rename to questions/00517-extreme-multiply/info.yml diff --git a/questions/517-extreme-multiply/template.ts b/questions/00517-extreme-multiply/template.ts similarity index 100% rename from questions/517-extreme-multiply/template.ts rename to questions/00517-extreme-multiply/template.ts diff --git a/questions/517-extreme-multiply/test-cases.ts b/questions/00517-extreme-multiply/test-cases.ts similarity index 97% rename from questions/517-extreme-multiply/test-cases.ts rename to questions/00517-extreme-multiply/test-cases.ts index a48b53cea..41414a3ed 100644 --- a/questions/517-extreme-multiply/test-cases.ts +++ b/questions/00517-extreme-multiply/test-cases.ts @@ -1,20 +1,20 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, '6'>>, - Expect, '15'>>, - Expect, '40'>>, - Expect, '0'>>, - Expect, '273'>>, - Expect, '13962361689'>>, - Expect, '9999'>>, - Expect, '170985150488'>>, - Expect, '100000'>>, - Expect, '2363474715'>>, - Expect, '891'>>, - Expect, '31500'>>, - Expect, '143'>>, - Expect, '0'>>, - Expect, '0'>>, - Expect, '0'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, '6'>>, + Expect, '15'>>, + Expect, '40'>>, + Expect, '0'>>, + Expect, '273'>>, + Expect, '13962361689'>>, + Expect, '9999'>>, + Expect, '170985150488'>>, + Expect, '100000'>>, + Expect, '2363474715'>>, + Expect, '891'>>, + Expect, '31500'>>, + Expect, '143'>>, + Expect, '0'>>, + Expect, '0'>>, + Expect, '0'>>, +] diff --git a/questions/527-medium-append-to-object/README.ja.md b/questions/00527-medium-append-to-object/README.ja.md similarity index 99% rename from questions/527-medium-append-to-object/README.ja.md rename to questions/00527-medium-append-to-object/README.ja.md index 361bfaa3a..8edf5adad 100644 --- a/questions/527-medium-append-to-object/README.ja.md +++ b/questions/00527-medium-append-to-object/README.ja.md @@ -1,12 +1,12 @@ -

Append to object 中級 #object-keys

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

- -インターフェースに新しいフィールドを追加する型を実装します。この型は、3 つの引数を受け取り、新しいフィールドを持つオブジェクトを出力しなければなりません。 - -例えば、 - -```ts -type Test = { id: '1' }; -type Result = AppendToObject; // expected to be { id: '1', value: 4 } -``` - -
戻る 解答を共有 解答を確認 +

Append to object 中級 #object-keys

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

+ +インターフェースに新しいフィールドを追加する型を実装します。この型は、3 つの引数を受け取り、新しいフィールドを持つオブジェクトを出力しなければなりません。 + +例えば、 + +```ts +type Test = { id: '1' }; +type Result = AppendToObject; // expected to be { id: '1', value: 4 } +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/527-medium-append-to-object/README.md b/questions/00527-medium-append-to-object/README.md similarity index 99% rename from questions/527-medium-append-to-object/README.md rename to questions/00527-medium-append-to-object/README.md index 0ce53b0c8..43bc276dc 100644 --- a/questions/527-medium-append-to-object/README.md +++ b/questions/00527-medium-append-to-object/README.md @@ -1,13 +1,13 @@ -

Append to object medium #object-keys

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

- -Implement a type that adds a new field to the interface. The type takes the three arguments. The output should be an object with the new field. - -For example - -```ts -type Test = { id: '1' } -type Result = AppendToObject // expected to be { id: '1', value: 4 } -``` - - -
Back Share your Solutions Check out Solutions +

Append to object medium #object-keys

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

+ +Implement a type that adds a new field to the interface. The type takes the three arguments. The output should be an object with the new field. + +For example + +```ts +type Test = { id: '1' } +type Result = AppendToObject // expected to be { id: '1', value: 4 } +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/527-medium-append-to-object/README.zh-CN.md b/questions/00527-medium-append-to-object/README.zh-CN.md similarity index 100% rename from questions/527-medium-append-to-object/README.zh-CN.md rename to questions/00527-medium-append-to-object/README.zh-CN.md diff --git a/questions/527-medium-append-to-object/info.yml b/questions/00527-medium-append-to-object/info.yml similarity index 100% rename from questions/527-medium-append-to-object/info.yml rename to questions/00527-medium-append-to-object/info.yml diff --git a/questions/527-medium-append-to-object/template.ts b/questions/00527-medium-append-to-object/template.ts similarity index 100% rename from questions/527-medium-append-to-object/template.ts rename to questions/00527-medium-append-to-object/template.ts diff --git a/questions/527-medium-append-to-object/test-cases.ts b/questions/00527-medium-append-to-object/test-cases.ts similarity index 94% rename from questions/527-medium-append-to-object/test-cases.ts rename to questions/00527-medium-append-to-object/test-cases.ts index a2521df73..a155d5873 100644 --- a/questions/527-medium-append-to-object/test-cases.ts +++ b/questions/00527-medium-append-to-object/test-cases.ts @@ -1,44 +1,44 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type test1 = { - key: 'cat' - value: 'green' -} - -type testExpect1 = { - key: 'cat' - value: 'green' - home: boolean -} - -type test2 = { - key: 'dog' | undefined - value: 'white' - sun: true -} - -type testExpect2 = { - key: 'dog' | undefined - value: 'white' - sun: true - home: 1 -} - -type test3 = { - key: 'cow' - value: 'yellow' - sun: false -} - -type testExpect3 = { - key: 'cow' - value: 'yellow' - sun: false - isMotherRussia: false | undefined -} - -type cases = [ - Expect, testExpect1>>, - Expect, testExpect2>>, - Expect, testExpect3>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type test1 = { + key: 'cat' + value: 'green' +} + +type testExpect1 = { + key: 'cat' + value: 'green' + home: boolean +} + +type test2 = { + key: 'dog' | undefined + value: 'white' + sun: true +} + +type testExpect2 = { + key: 'dog' | undefined + value: 'white' + sun: true + home: 1 +} + +type test3 = { + key: 'cow' + value: 'yellow' + sun: false +} + +type testExpect3 = { + key: 'cow' + value: 'yellow' + sun: false + isMotherRussia: false | undefined +} + +type cases = [ + Expect, testExpect1>>, + Expect, testExpect2>>, + Expect, testExpect3>>, +] diff --git a/questions/529-medium-absolute/README.ja.md b/questions/00529-medium-absolute/README.ja.md similarity index 99% rename from questions/529-medium-absolute/README.ja.md rename to questions/00529-medium-absolute/README.ja.md index 8b384205c..8713ce43e 100644 --- a/questions/529-medium-absolute/README.ja.md +++ b/questions/00529-medium-absolute/README.ja.md @@ -1,12 +1,12 @@ -

Absolute 中級 #math #template-literal

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

- -srting, number または bigint を受け取り、正の数を出力する `Absolute` 型を実装します。 - -例えば - -```ts -type Test = -100; -type Result = Absolute; // expected to be "100" -``` - -
戻る 解答を共有 解答を確認 +

Absolute 中級 #math #template-literal

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

+ +srting, number または bigint を受け取り、正の数を出力する `Absolute` 型を実装します。 + +例えば + +```ts +type Test = -100; +type Result = Absolute; // expected to be "100" +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/529-medium-absolute/README.md b/questions/00529-medium-absolute/README.md similarity index 99% rename from questions/529-medium-absolute/README.md rename to questions/00529-medium-absolute/README.md index 329efd24d..d977604ac 100644 --- a/questions/529-medium-absolute/README.md +++ b/questions/00529-medium-absolute/README.md @@ -1,12 +1,12 @@ -

Absolute medium #math #template-literal

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

- -Implement the `Absolute` type. A type that take string, number or bigint. The output should be a positive number string - -For example - -```ts -type Test = -100; -type Result = Absolute; // expected to be "100" -``` - -
Back Share your Solutions Check out Solutions +

Absolute medium #math #template-literal

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

+ +Implement the `Absolute` type. A type that take string, number or bigint. The output should be a positive number string + +For example + +```ts +type Test = -100; +type Result = Absolute; // expected to be "100" +``` + +
Back Share your Solutions Check out Solutions diff --git a/questions/529-medium-absolute/README.zh-CN.md b/questions/00529-medium-absolute/README.zh-CN.md similarity index 100% rename from questions/529-medium-absolute/README.zh-CN.md rename to questions/00529-medium-absolute/README.zh-CN.md diff --git a/questions/529-medium-absolute/info.yml b/questions/00529-medium-absolute/info.yml similarity index 100% rename from questions/529-medium-absolute/info.yml rename to questions/00529-medium-absolute/info.yml diff --git a/questions/529-medium-absolute/template.ts b/questions/00529-medium-absolute/template.ts similarity index 100% rename from questions/529-medium-absolute/template.ts rename to questions/00529-medium-absolute/template.ts diff --git a/questions/529-medium-absolute/test-cases.ts b/questions/00529-medium-absolute/test-cases.ts similarity index 97% rename from questions/529-medium-absolute/test-cases.ts rename to questions/00529-medium-absolute/test-cases.ts index c1947d967..57f701250 100644 --- a/questions/529-medium-absolute/test-cases.ts +++ b/questions/00529-medium-absolute/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, '0'>>, - Expect, '0'>>, - Expect, '10'>>, - Expect, '5'>>, - Expect, '0'>>, - Expect, '0'>>, - Expect, '10'>>, - Expect, '5'>>, - Expect, '1000000'>>, - Expect, '9999'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, '0'>>, + Expect, '0'>>, + Expect, '10'>>, + Expect, '5'>>, + Expect, '0'>>, + Expect, '0'>>, + Expect, '10'>>, + Expect, '5'>>, + Expect, '1000000'>>, + Expect, '9999'>>, +] diff --git a/questions/531-medium-string-to-union/README.ja.md b/questions/00531-medium-string-to-union/README.ja.md similarity index 99% rename from questions/531-medium-string-to-union/README.ja.md rename to questions/00531-medium-string-to-union/README.ja.md index 9765d8304..ad3b7c4f8 100644 --- a/questions/531-medium-string-to-union/README.ja.md +++ b/questions/00531-medium-string-to-union/README.ja.md @@ -1,12 +1,12 @@ -

String to Union 中級 #union #string

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

- -受け取った文字列を Union 型に変換する型を実装します。 - -例えば - -```ts -type Test = '123'; -type Result = StringToUnion; // expected to be "1" | "2" | "3" -``` - -
戻る 解答を共有 解答を確認 +

String to Union 中級 #union #string

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文

+ +受け取った文字列を Union 型に変換する型を実装します。 + +例えば + +```ts +type Test = '123'; +type Result = StringToUnion; // expected to be "1" | "2" | "3" +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/531-medium-string-to-union/README.md b/questions/00531-medium-string-to-union/README.md similarity index 99% rename from questions/531-medium-string-to-union/README.md rename to questions/00531-medium-string-to-union/README.md index 3cfbf6dfc..48133adec 100644 --- a/questions/531-medium-string-to-union/README.md +++ b/questions/00531-medium-string-to-union/README.md @@ -1,12 +1,12 @@ -

String to Union medium #union #string

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

- -Implement the String to Union type. Type take string argument. The output should be a union of input letters - -For example - -```ts -type Test = '123'; -type Result = StringToUnion; // expected to be "1" | "2" | "3" -``` - -
Back Share your Solutions Check out Solutions +

String to Union medium #union #string

by Andrey Krasovsky @bre30kra69cs

Take the Challenge    简体中文 日本語

+ +Implement the String to Union type. Type take string argument. The output should be a union of input letters + +For example + +```ts +type Test = '123'; +type Result = StringToUnion; // expected to be "1" | "2" | "3" +``` + +
Back Share your Solutions Check out Solutions diff --git a/questions/531-medium-string-to-union/README.zh-CN.md b/questions/00531-medium-string-to-union/README.zh-CN.md similarity index 100% rename from questions/531-medium-string-to-union/README.zh-CN.md rename to questions/00531-medium-string-to-union/README.zh-CN.md diff --git a/questions/531-medium-string-to-union/info.yml b/questions/00531-medium-string-to-union/info.yml similarity index 100% rename from questions/531-medium-string-to-union/info.yml rename to questions/00531-medium-string-to-union/info.yml diff --git a/questions/531-medium-string-to-union/template.ts b/questions/00531-medium-string-to-union/template.ts similarity index 100% rename from questions/531-medium-string-to-union/template.ts rename to questions/00531-medium-string-to-union/template.ts diff --git a/questions/531-medium-string-to-union/test-cases.ts b/questions/00531-medium-string-to-union/test-cases.ts similarity index 97% rename from questions/531-medium-string-to-union/test-cases.ts rename to questions/00531-medium-string-to-union/test-cases.ts index 5b728eca0..9a913f335 100644 --- a/questions/531-medium-string-to-union/test-cases.ts +++ b/questions/00531-medium-string-to-union/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, never>>, - Expect, 't'>>, - Expect, 'h' | 'e' | 'l' | 'l' | 'o'>>, - Expect, 'c' | 'o' | 'r' | 'o' | 'n' | 'a' | 'v' | 'i' | 'r' | 'u' | 's'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, never>>, + Expect, 't'>>, + Expect, 'h' | 'e' | 'l' | 'l' | 'o'>>, + Expect, 'c' | 'o' | 'r' | 'o' | 'n' | 'a' | 'v' | 'i' | 'r' | 'u' | 's'>>, +] diff --git a/questions/533-easy-concat/README.ja.md b/questions/00533-easy-concat/README.ja.md similarity index 81% rename from questions/533-easy-concat/README.ja.md rename to questions/00533-easy-concat/README.ja.md index 133678c84..15e9146e2 100644 --- a/questions/533-easy-concat/README.ja.md +++ b/questions/00533-easy-concat/README.ja.md @@ -1,11 +1,11 @@ -

Concat 初級 #array

by Andrey Krasovsky @bre30kra69cs

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

- -JavaScript の`Array.concat`関数を型システムに実装します。この型は 2 つの引数を受け取り、受け取ったイテレータの要素を順に含む新しい配列を返します。 - -例えば - -```ts -type Result = Concat<[1], [2]>; // expected to be [1, 2] -``` - -
戻る 解答を共有 解答を確認

関連する課題

3057・Push 3060・Unshift +

Concat 初級 #array

by Andrey Krasovsky @bre30kra69cs

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

+ +JavaScript の`Array.concat`関数を型システムに実装します。この型は 2 つの引数を受け取り、受け取ったイテレータの要素を順に含む新しい配列を返します。 + +例えば + +```ts +type Result = Concat<[1], [2]>; // expected to be [1, 2] +``` + +
戻る 解答を共有 解答を確認

関連する課題

3057・Push 3060・Unshift diff --git a/questions/533-easy-concat/README.ko.md b/questions/00533-easy-concat/README.ko.md similarity index 80% rename from questions/533-easy-concat/README.ko.md rename to questions/00533-easy-concat/README.ko.md index e871b5bc4..fcf41f15a 100644 --- a/questions/533-easy-concat/README.ko.md +++ b/questions/00533-easy-concat/README.ko.md @@ -1,12 +1,12 @@ -

Concat 쉬움 #array

by Andrey Krasovsky @bre30kra69cs

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

- -JavaScript의 `Array.concat` 함수를 타입 시스템에서 구현하세요. 타입은 두 인수를 받고, 인수를 왼쪽부터 concat한 새로운 배열을 반환해야 합니다. - -예시: - -```ts -type Result = Concat<[1], [2]> // expected to be [1, 2] -``` - - -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

3057・Push 3060・Unshift +

Concat 쉬움 #array

by Andrey Krasovsky @bre30kra69cs

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

+ +JavaScript의 `Array.concat` 함수를 타입 시스템에서 구현하세요. 타입은 두 인수를 받고, 인수를 왼쪽부터 concat한 새로운 배열을 반환해야 합니다. + +예시: + +```ts +type Result = Concat<[1], [2]> // expected to be [1, 2] +``` + + +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

3057・Push 3060・Unshift diff --git a/questions/533-easy-concat/README.md b/questions/00533-easy-concat/README.md similarity index 80% rename from questions/533-easy-concat/README.md rename to questions/00533-easy-concat/README.md index ee6daafa8..a94dbf974 100644 --- a/questions/533-easy-concat/README.md +++ b/questions/00533-easy-concat/README.md @@ -1,12 +1,12 @@ -

Concat easy #array

by Andrey Krasovsky @bre30kra69cs

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

- -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 - -```ts -type Result = Concat<[1], [2]> // expected to be [1, 2] -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

3057・Push 3060・Unshift +

Concat easy #array

by Andrey Krasovsky @bre30kra69cs

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

+ +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 + +```ts +type Result = Concat<[1], [2]> // expected to be [1, 2] +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

3057・Push 3060・Unshift diff --git a/questions/533-easy-concat/README.zh-CN.md b/questions/00533-easy-concat/README.zh-CN.md similarity index 80% rename from questions/533-easy-concat/README.zh-CN.md rename to questions/00533-easy-concat/README.zh-CN.md index 2993eccfa..8d5757a93 100644 --- a/questions/533-easy-concat/README.zh-CN.md +++ b/questions/00533-easy-concat/README.zh-CN.md @@ -1,13 +1,13 @@ -

Concat 简单 #array

by Andrey Krasovsky @bre30kra69cs

接受挑战    English 日本語 한국어

- -在类型系统里实现 JavaScript 内置的 `Array.concat` 方法,这个类型接受两个参数,返回的新数组类型应该按照输入参数从左到右的顺序合并为一个新的数组。 - -举例, - -```ts -type Result = Concat<[1], [2]> // expected to be [1, 2] -``` - - - -
返回首页 分享你的解答 查看解答

相关挑战

3057・Push 3060・Unshift +

Concat 简单 #array

by Andrey Krasovsky @bre30kra69cs

接受挑战    English 日本語 한국어

+ +在类型系统里实现 JavaScript 内置的 `Array.concat` 方法,这个类型接受两个参数,返回的新数组类型应该按照输入参数从左到右的顺序合并为一个新的数组。 + +举例, + +```ts +type Result = Concat<[1], [2]> // expected to be [1, 2] +``` + + + +
返回首页 分享你的解答 查看解答

相关挑战

3057・Push 3060・Unshift diff --git a/questions/533-easy-concat/info.yml b/questions/00533-easy-concat/info.yml similarity index 100% rename from questions/533-easy-concat/info.yml rename to questions/00533-easy-concat/info.yml diff --git a/questions/533-easy-concat/template.ts b/questions/00533-easy-concat/template.ts similarity index 100% rename from questions/533-easy-concat/template.ts rename to questions/00533-easy-concat/template.ts diff --git a/questions/533-easy-concat/test-cases.ts b/questions/00533-easy-concat/test-cases.ts similarity index 97% rename from questions/533-easy-concat/test-cases.ts rename to questions/00533-easy-concat/test-cases.ts index f23aa6566..89b699a99 100644 --- a/questions/533-easy-concat/test-cases.ts +++ b/questions/00533-easy-concat/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [1]>>, - Expect, [1, 2, 3, 4]>>, - Expect, ['1', 2, '3', false, boolean, '4']>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [1]>>, + Expect, [1, 2, 3, 4]>>, + Expect, ['1', 2, '3', false, boolean, '4']>>, +] diff --git a/questions/545-hard-printf/README.ja.md b/questions/00545-hard-printf/README.ja.md similarity index 99% rename from questions/545-hard-printf/README.ja.md rename to questions/00545-hard-printf/README.ja.md index 367bfce27..416a1a142 100644 --- a/questions/545-hard-printf/README.ja.md +++ b/questions/00545-hard-printf/README.ja.md @@ -1,14 +1,14 @@ -

printf 上級 #template-literal

by null @BestMaster-YS

挑戦する    English

- -汎用的な`Format`を実装します。 - -例えば、 - -```ts -type FormatCase1 = Format<'%sabc'>; // FormatCase1 : string => string -type FormatCase2 = Format<'%s%dabc'>; // FormatCase2 : string => number => string -type FormatCase3 = Format<'sdabc'>; // FormatCase3 : string -type FormatCase4 = Format<'sd%abc'>; // FormatCase4 : string -``` - -
戻る 解答を共有 解答を確認 +

printf 上級 #template-literal

by null @BestMaster-YS

挑戦する    English

+ +汎用的な`Format`を実装します。 + +例えば、 + +```ts +type FormatCase1 = Format<'%sabc'>; // FormatCase1 : string => string +type FormatCase2 = Format<'%s%dabc'>; // FormatCase2 : string => number => string +type FormatCase3 = Format<'sdabc'>; // FormatCase3 : string +type FormatCase4 = Format<'sd%abc'>; // FormatCase4 : string +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/545-hard-printf/README.md b/questions/00545-hard-printf/README.md similarity index 99% rename from questions/545-hard-printf/README.md rename to questions/00545-hard-printf/README.md index 15ea0cc2a..ce6faec3d 100644 --- a/questions/545-hard-printf/README.md +++ b/questions/00545-hard-printf/README.md @@ -1,14 +1,14 @@

printf hard #template-literal

by null @BestMaster-YS

Take the Challenge    日本語

-Implement `Format` generic. - -For example, - -```ts -type FormatCase1 = Format<"%sabc"> // FormatCase1 : string => string -type FormatCase2 = Format<"%s%dabc"> // FormatCase2 : string => number => string -type FormatCase3 = Format<"sdabc"> // FormatCase3 : string -type FormatCase4 = Format<"sd%abc"> // FormatCase4 : string +Implement `Format` generic. + +For example, + +```ts +type FormatCase1 = Format<"%sabc"> // FormatCase1 : string => string +type FormatCase2 = Format<"%s%dabc"> // FormatCase2 : string => number => string +type FormatCase3 = Format<"sdabc"> // FormatCase3 : string +type FormatCase4 = Format<"sd%abc"> // FormatCase4 : string ``` diff --git a/questions/545-hard-printf/info.yml b/questions/00545-hard-printf/info.yml similarity index 100% rename from questions/545-hard-printf/info.yml rename to questions/00545-hard-printf/info.yml diff --git a/questions/545-hard-printf/template.ts b/questions/00545-hard-printf/template.ts similarity index 100% rename from questions/545-hard-printf/template.ts rename to questions/00545-hard-printf/template.ts diff --git a/questions/545-hard-printf/test-cases.ts b/questions/00545-hard-printf/test-cases.ts similarity index 97% rename from questions/545-hard-printf/test-cases.ts rename to questions/00545-hard-printf/test-cases.ts index e30cf050b..900316779 100644 --- a/questions/545-hard-printf/test-cases.ts +++ b/questions/00545-hard-printf/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, string>>, - Expect, (s1: string) => string>>, - Expect, (d1: number) => string>>, - Expect, (d1: number) => (s1: string) => string>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, string>>, + Expect, (s1: string) => string>>, + Expect, (d1: number) => string>>, + Expect, (d1: number) => (s1: string) => string>>, +] diff --git a/questions/553-hard-deep-object-to-unique/README.ja.md b/questions/00553-hard-deep-object-to-unique/README.ja.md similarity index 98% rename from questions/553-hard-deep-object-to-unique/README.ja.md rename to questions/00553-hard-deep-object-to-unique/README.ja.md index fdb56f8ad..6640904ac 100644 --- a/questions/553-hard-deep-object-to-unique/README.ja.md +++ b/questions/00553-hard-deep-object-to-unique/README.ja.md @@ -1,31 +1,31 @@ -

Deep object to unique 上級 #deep

by null @uid11

挑戦する    English

- -TypeScript は構造的型システムを持っていますが、場合によっては(公称型システムのように)あらかじめ定義されたユニークなオブジェクトだけを受け入れ、required なフィールドを持つオブジェクトは受け入れないようにしたいこともあるでしょう。 - -引数にオブジェクトを受け取り、引数に含まれる全てのオブジェクトの文字列と数値のキー、およびこれらのキーの値のプロパティーを保持しながら、引数のオブジェクトとそれに含まれるネストしたオブジェクト全てをユニークにする型を実装します。 - -元の型と実装した型のアウトプットの型は相互に代入可能でなければなりませんが、同一の型であってはいけません。 - -例えば、 - -```ts -import { Equal } from '@type-challenges/utils'; - -type Foo = { foo: 2; bar: { 0: 1 }; baz: { 0: 1 } }; - -type UniqFoo = DeepObjectToUniq; - -declare let foo: Foo; -declare let uniqFoo: UniqFoo; - -uniqFoo = foo; // ok -foo = uniqFoo; // ok - -type T0 = Equal; // false -type T1 = UniqFoo['foo']; // 2 -type T2 = Equal; // false -type T3 = UniqFoo['bar'][0]; // 1 -type T4 = Equal; // true -``` - -
戻る 解答を共有 解答を確認 +

Deep object to unique 上級 #deep

by null @uid11

挑戦する    English

+ +TypeScript は構造的型システムを持っていますが、場合によっては(公称型システムのように)あらかじめ定義されたユニークなオブジェクトだけを受け入れ、required なフィールドを持つオブジェクトは受け入れないようにしたいこともあるでしょう。 + +引数にオブジェクトを受け取り、引数に含まれる全てのオブジェクトの文字列と数値のキー、およびこれらのキーの値のプロパティーを保持しながら、引数のオブジェクトとそれに含まれるネストしたオブジェクト全てをユニークにする型を実装します。 + +元の型と実装した型のアウトプットの型は相互に代入可能でなければなりませんが、同一の型であってはいけません。 + +例えば、 + +```ts +import { Equal } from '@type-challenges/utils'; + +type Foo = { foo: 2; bar: { 0: 1 }; baz: { 0: 1 } }; + +type UniqFoo = DeepObjectToUniq; + +declare let foo: Foo; +declare let uniqFoo: UniqFoo; + +uniqFoo = foo; // ok +foo = uniqFoo; // ok + +type T0 = Equal; // false +type T1 = UniqFoo['foo']; // 2 +type T2 = Equal; // false +type T3 = UniqFoo['bar'][0]; // 1 +type T4 = Equal; // true +``` + +
戻る 解答を共有 解答を確認 diff --git a/questions/553-hard-deep-object-to-unique/README.md b/questions/00553-hard-deep-object-to-unique/README.md similarity index 98% rename from questions/553-hard-deep-object-to-unique/README.md rename to questions/00553-hard-deep-object-to-unique/README.md index 90986adbe..e863b13e7 100644 --- a/questions/553-hard-deep-object-to-unique/README.md +++ b/questions/00553-hard-deep-object-to-unique/README.md @@ -1,31 +1,31 @@

Deep object to unique hard #deep

by null @uid11

Take the Challenge    日本語

-TypeScript has structural type system, but sometimes you want a function to accept only some previously well-defined unique objects (as in the nominal type system), and not any objects that have the required fields. - -Create a type that takes an object and makes it and all deeply nested objects in it unique, while preserving the string and numeric keys of all objects, and the values of all properties on these keys. - -The original type and the resulting unique type must be mutually assignable, but not identical. - -For example, - -```ts -import { Equal } from "@type-challenges/utils" - -type Foo = { foo: 2; bar: { 0: 1 }; baz: { 0: 1 } } - -type UniqFoo = DeepObjectToUniq - -declare let foo: Foo -declare let uniqFoo: UniqFoo - -uniqFoo = foo // ok -foo = uniqFoo // ok - -type T0 = Equal // false -type T1 = UniqFoo["foo"] // 2 -type T2 = Equal // false -type T3 = UniqFoo["bar"][0] // 1 -type T4 = Equal // true +TypeScript has structural type system, but sometimes you want a function to accept only some previously well-defined unique objects (as in the nominal type system), and not any objects that have the required fields. + +Create a type that takes an object and makes it and all deeply nested objects in it unique, while preserving the string and numeric keys of all objects, and the values of all properties on these keys. + +The original type and the resulting unique type must be mutually assignable, but not identical. + +For example, + +```ts +import { Equal } from "@type-challenges/utils" + +type Foo = { foo: 2; bar: { 0: 1 }; baz: { 0: 1 } } + +type UniqFoo = DeepObjectToUniq + +declare let foo: Foo +declare let uniqFoo: UniqFoo + +uniqFoo = foo // ok +foo = uniqFoo // ok + +type T0 = Equal // false +type T1 = UniqFoo["foo"] // 2 +type T2 = Equal // false +type T3 = UniqFoo["bar"][0] // 1 +type T4 = Equal // true ``` diff --git a/questions/553-hard-deep-object-to-unique/info.yml b/questions/00553-hard-deep-object-to-unique/info.yml similarity index 100% rename from questions/553-hard-deep-object-to-unique/info.yml rename to questions/00553-hard-deep-object-to-unique/info.yml diff --git a/questions/553-hard-deep-object-to-unique/template.ts b/questions/00553-hard-deep-object-to-unique/template.ts similarity index 100% rename from questions/553-hard-deep-object-to-unique/template.ts rename to questions/00553-hard-deep-object-to-unique/template.ts diff --git a/questions/553-hard-deep-object-to-unique/test-cases.ts b/questions/00553-hard-deep-object-to-unique/test-cases.ts similarity index 96% rename from questions/553-hard-deep-object-to-unique/test-cases.ts rename to questions/00553-hard-deep-object-to-unique/test-cases.ts index ce1d9ed11..61d65e14e 100644 --- a/questions/553-hard-deep-object-to-unique/test-cases.ts +++ b/questions/00553-hard-deep-object-to-unique/test-cases.ts @@ -1,25 +1,25 @@ -import type { Equal, IsFalse, IsTrue } from '@type-challenges/utils' - -type Quz = { quz: 4 } - -type Foo = { foo: 2; baz: Quz; bar: Quz } -type Bar = { foo: 2; baz: Quz; bar: Quz & { quzz?: 0 } } - -type UniqFoo = DeepObjectToUniq -type UniqBar = DeepObjectToUniq - -declare let foo: Foo -declare let uniqFoo: UniqFoo - -uniqFoo = foo -foo = uniqFoo - -type cases = [ - IsFalse>, - IsTrue>, - IsTrue>, - IsFalse>, - IsFalse>, - IsTrue>, - IsTrue>, +import type { Equal, IsFalse, IsTrue } from '@type-challenges/utils' + +type Quz = { quz: 4 } + +type Foo = { foo: 2; baz: Quz; bar: Quz } +type Bar = { foo: 2; baz: Quz; bar: Quz & { quzz?: 0 } } + +type UniqFoo = DeepObjectToUniq +type UniqBar = DeepObjectToUniq + +declare let foo: Foo +declare let uniqFoo: UniqFoo + +uniqFoo = foo +foo = uniqFoo + +type cases = [ + IsFalse>, + IsTrue>, + IsTrue>, + IsFalse>, + IsFalse>, + IsTrue>, + IsTrue>, ] diff --git a/questions/599-medium-merge/README.ja.md b/questions/00599-medium-merge/README.ja.md similarity index 100% rename from questions/599-medium-merge/README.ja.md rename to questions/00599-medium-merge/README.ja.md diff --git a/questions/599-medium-merge/README.md b/questions/00599-medium-merge/README.md similarity index 100% rename from questions/599-medium-merge/README.md rename to questions/00599-medium-merge/README.md diff --git a/questions/599-medium-merge/README.zh-CN.md b/questions/00599-medium-merge/README.zh-CN.md similarity index 100% rename from questions/599-medium-merge/README.zh-CN.md rename to questions/00599-medium-merge/README.zh-CN.md diff --git a/questions/599-medium-merge/info.yml b/questions/00599-medium-merge/info.yml similarity index 100% rename from questions/599-medium-merge/info.yml rename to questions/00599-medium-merge/info.yml diff --git a/questions/599-medium-merge/template.ts b/questions/00599-medium-merge/template.ts similarity index 100% rename from questions/599-medium-merge/template.ts rename to questions/00599-medium-merge/template.ts diff --git a/questions/599-medium-merge/test-cases.ts b/questions/00599-medium-merge/test-cases.ts similarity index 93% rename from questions/599-medium-merge/test-cases.ts rename to questions/00599-medium-merge/test-cases.ts index 94433ad16..892f5c9c5 100644 --- a/questions/599-medium-merge/test-cases.ts +++ b/questions/00599-medium-merge/test-cases.ts @@ -1,18 +1,18 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Foo = { - a: number - b: string -} -type Bar = { - b: number - c: boolean -} - -type cases = [ - Expect, { - a: number - b: number - c: boolean - }>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Foo = { + a: number + b: string +} +type Bar = { + b: number + c: boolean +} + +type cases = [ + Expect, { + a: number + b: number + c: boolean + }>>, +] diff --git a/questions/610-medium-camelcase/README.md b/questions/00610-medium-camelcase/README.md similarity index 72% rename from questions/610-medium-camelcase/README.md rename to questions/00610-medium-camelcase/README.md index 7a2b85f1b..0f9c5fb59 100644 --- a/questions/610-medium-camelcase/README.md +++ b/questions/00610-medium-camelcase/README.md @@ -3,4 +3,4 @@ `for-bar-baz` -> `forBarBaz` -
Back Share your Solutions Check out Solutions

Related Challenges

612・KebabCase 114・CamelCase \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

612・KebabCase 114・CamelCase \ No newline at end of file diff --git a/questions/610-medium-camelcase/info.yml b/questions/00610-medium-camelcase/info.yml similarity index 100% rename from questions/610-medium-camelcase/info.yml rename to questions/00610-medium-camelcase/info.yml diff --git a/questions/610-medium-camelcase/template.ts b/questions/00610-medium-camelcase/template.ts similarity index 100% rename from questions/610-medium-camelcase/template.ts rename to questions/00610-medium-camelcase/template.ts diff --git a/questions/610-medium-camelcase/test-cases.ts b/questions/00610-medium-camelcase/test-cases.ts similarity index 97% rename from questions/610-medium-camelcase/test-cases.ts rename to questions/00610-medium-camelcase/test-cases.ts index bbf4a6347..09be8b31e 100644 --- a/questions/610-medium-camelcase/test-cases.ts +++ b/questions/00610-medium-camelcase/test-cases.ts @@ -1,16 +1,16 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'fooBarBaz'>>, - Expect, 'foo-Bar-Baz'>>, - Expect, 'foo-BarBaz'>>, - Expect, 'fooBar'>>, - Expect, 'foo_bar'>>, - Expect, 'foo-Bar---Baz'>>, - Expect, 'aBC'>>, - Expect, 'aBC-'>>, - Expect, 'ABC'>>, - Expect, '-'>>, - Expect, ''>>, - Expect, '😎'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'fooBarBaz'>>, + Expect, 'foo-Bar-Baz'>>, + Expect, 'foo-BarBaz'>>, + Expect, 'fooBar'>>, + Expect, 'foo_bar'>>, + Expect, 'foo-Bar---Baz'>>, + Expect, 'aBC'>>, + Expect, 'aBC-'>>, + Expect, 'ABC'>>, + Expect, '-'>>, + Expect, ''>>, + Expect, '😎'>>, +] diff --git a/questions/612-medium-kebabcase/README.md b/questions/00612-medium-kebabcase/README.md similarity index 72% rename from questions/612-medium-kebabcase/README.md rename to questions/00612-medium-kebabcase/README.md index d35501cdd..80dffb57d 100644 --- a/questions/612-medium-kebabcase/README.md +++ b/questions/00612-medium-kebabcase/README.md @@ -3,4 +3,4 @@ `FooBarBaz` -> `foo-bar-baz` -
Back Share your Solutions Check out Solutions

Related Challenges

610・CamelCase 114・CamelCase +
Back Share your Solutions Check out Solutions

Related Challenges

610・CamelCase 114・CamelCase diff --git a/questions/612-medium-kebabcase/info.yml b/questions/00612-medium-kebabcase/info.yml similarity index 100% rename from questions/612-medium-kebabcase/info.yml rename to questions/00612-medium-kebabcase/info.yml diff --git a/questions/612-medium-kebabcase/template.ts b/questions/00612-medium-kebabcase/template.ts similarity index 100% rename from questions/612-medium-kebabcase/template.ts rename to questions/00612-medium-kebabcase/template.ts diff --git a/questions/612-medium-kebabcase/test-cases.ts b/questions/00612-medium-kebabcase/test-cases.ts similarity index 97% rename from questions/612-medium-kebabcase/test-cases.ts rename to questions/00612-medium-kebabcase/test-cases.ts index 0053b0759..9afde5932 100644 --- a/questions/612-medium-kebabcase/test-cases.ts +++ b/questions/00612-medium-kebabcase/test-cases.ts @@ -1,13 +1,13 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'foo-bar-baz'>>, - Expect, 'foo-bar-baz'>>, - Expect, 'foo-bar'>>, - Expect, 'foo_bar'>>, - Expect, 'foo--bar'>>, - Expect, 'a-b-c'>>, - Expect, '-'>>, - Expect, ''>>, - Expect, '😎'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'foo-bar-baz'>>, + Expect, 'foo-bar-baz'>>, + Expect, 'foo-bar'>>, + Expect, 'foo_bar'>>, + Expect, 'foo--bar'>>, + Expect, 'a-b-c'>>, + Expect, '-'>>, + Expect, ''>>, + Expect, '😎'>>, +] diff --git a/questions/645-medium-diff/README.md b/questions/00645-medium-diff/README.md similarity index 100% rename from questions/645-medium-diff/README.md rename to questions/00645-medium-diff/README.md diff --git a/questions/645-medium-diff/README.zh-CN.md b/questions/00645-medium-diff/README.zh-CN.md similarity index 100% rename from questions/645-medium-diff/README.zh-CN.md rename to questions/00645-medium-diff/README.zh-CN.md diff --git a/questions/645-medium-diff/info.yml b/questions/00645-medium-diff/info.yml similarity index 100% rename from questions/645-medium-diff/info.yml rename to questions/00645-medium-diff/info.yml diff --git a/questions/645-medium-diff/template.ts b/questions/00645-medium-diff/template.ts similarity index 95% rename from questions/645-medium-diff/template.ts rename to questions/00645-medium-diff/template.ts index 378b026b6..05cfdd38f 100644 --- a/questions/645-medium-diff/template.ts +++ b/questions/00645-medium-diff/template.ts @@ -1 +1 @@ -type Diff = any +type Diff = any diff --git a/questions/645-medium-diff/test-cases.ts b/questions/00645-medium-diff/test-cases.ts similarity index 95% rename from questions/645-medium-diff/test-cases.ts rename to questions/00645-medium-diff/test-cases.ts index af98bba3e..c4728de9d 100644 --- a/questions/645-medium-diff/test-cases.ts +++ b/questions/00645-medium-diff/test-cases.ts @@ -1,22 +1,22 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Foo = { - name: string - age: string -} -type Bar = { - name: string - age: string - gender: number -} -type Coo = { - name: string - gender: number -} - -type cases = [ - Expect, { gender: number }>>, - Expect, { gender: number }>>, - Expect, { age: string; gender: number }>>, - Expect, { age: string; gender: number }>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Foo = { + name: string + age: string +} +type Bar = { + name: string + age: string + gender: number +} +type Coo = { + name: string + gender: number +} + +type cases = [ + Expect, { gender: number }>>, + Expect, { gender: number }>>, + Expect, { age: string; gender: number }>>, + Expect, { age: string; gender: number }>>, +] diff --git a/questions/651-hard-length-of-string-2/README.ja.md b/questions/00651-hard-length-of-string-2/README.ja.md similarity index 88% rename from questions/651-hard-length-of-string-2/README.ja.md rename to questions/00651-hard-length-of-string-2/README.ja.md index 947561629..a5b482dad 100644 --- a/questions/651-hard-length-of-string-2/README.ja.md +++ b/questions/00651-hard-length-of-string-2/README.ja.md @@ -1,11 +1,11 @@ -

Length of String 2 上級 #template-literal

by null @uid11

挑戦する    English

- -テンプレート文字列の長さを計算する`LengthOfString`を実装します。([298 - Length of String](https://tsch.js.org/298)と同じような型): - -```ts -type T0 = LengthOfString<'foo'>; // 3 -``` - -この課題で実装する型は、数百文字の長さの文字列をサポートしなければなりません(通常の再帰的な文字列長の計算は、TS の再帰的な関数呼び出しの深さによって制限されています、つまり、45 文字程度までの文字列をサポートしています)。 - -
戻る 解答を共有 解答を確認

関連する課題

298・Length of String +

Length of String 2 上級 #template-literal

by null @uid11

挑戦する    English

+ +テンプレート文字列の長さを計算する`LengthOfString`を実装します。([298 - Length of String](https://tsch.js.org/298)と同じような型): + +```ts +type T0 = LengthOfString<'foo'>; // 3 +``` + +この課題で実装する型は、数百文字の長さの文字列をサポートしなければなりません(通常の再帰的な文字列長の計算は、TS の再帰的な関数呼び出しの深さによって制限されています、つまり、45 文字程度までの文字列をサポートしています)。 + +
戻る 解答を共有 解答を確認

関連する課題

298・Length of String diff --git a/questions/651-hard-length-of-string-2/README.md b/questions/00651-hard-length-of-string-2/README.md similarity index 87% rename from questions/651-hard-length-of-string-2/README.md rename to questions/00651-hard-length-of-string-2/README.md index f8fef8ec5..9115d9e4b 100644 --- a/questions/651-hard-length-of-string-2/README.md +++ b/questions/00651-hard-length-of-string-2/README.md @@ -1,12 +1,12 @@

Length of String 2 hard #template-literal

by null @uid11

Take the Challenge    日本語

-Implement a type `LengthOfString` that calculates the length of the template string (as in [298 - Length of String](https://tsch.js.org/298)): - -```ts -type T0 = LengthOfString<"foo"> // 3 -``` - +Implement a type `LengthOfString` that calculates the length of the template string (as in [298 - Length of String](https://tsch.js.org/298)): + +```ts +type T0 = LengthOfString<"foo"> // 3 +``` + The type must support strings several hundred characters long (the usual recursive calculation of the string length is limited by the depth of recursive function calls in TS, that is, it supports strings up to about 45 characters long). -
Back Share your Solutions Check out Solutions

Related Challenges

298・Length of String \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

298・Length of String \ No newline at end of file diff --git a/questions/651-hard-length-of-string-2/info.yml b/questions/00651-hard-length-of-string-2/info.yml similarity index 100% rename from questions/651-hard-length-of-string-2/info.yml rename to questions/00651-hard-length-of-string-2/info.yml diff --git a/questions/651-hard-length-of-string-2/template.ts b/questions/00651-hard-length-of-string-2/template.ts similarity index 100% rename from questions/651-hard-length-of-string-2/template.ts rename to questions/00651-hard-length-of-string-2/template.ts diff --git a/questions/651-hard-length-of-string-2/test-cases.ts b/questions/00651-hard-length-of-string-2/test-cases.ts similarity index 98% rename from questions/651-hard-length-of-string-2/test-cases.ts rename to questions/00651-hard-length-of-string-2/test-cases.ts index 0d92695f9..3daedb6f6 100644 --- a/questions/651-hard-length-of-string-2/test-cases.ts +++ b/questions/00651-hard-length-of-string-2/test-cases.ts @@ -1,29 +1,29 @@ -import type { Equal, IsTrue } from '@type-challenges/utils' - -type cases = [ - IsTrue, 0>>, - IsTrue, 1>>, - IsTrue, 2>>, - IsTrue, 3>>, - IsTrue, 4>>, - IsTrue, 5>>, - IsTrue, 6>>, - IsTrue, 7>>, - IsTrue, 8>>, - IsTrue, 9>>, - IsTrue, 10>>, - IsTrue, 11>>, - IsTrue, 12>>, - IsTrue, 13>>, - IsTrue, 14>>, - IsTrue, 15>>, - IsTrue, 16>>, - IsTrue, 17>>, - IsTrue, 18>>, - IsTrue, 19>>, - IsTrue, 20>>, - IsTrue, 21>>, - IsTrue, 22>>, - IsTrue, 23>>, - IsTrue, 272>>, +import type { Equal, IsTrue } from '@type-challenges/utils' + +type cases = [ + IsTrue, 0>>, + IsTrue, 1>>, + IsTrue, 2>>, + IsTrue, 3>>, + IsTrue, 4>>, + IsTrue, 5>>, + IsTrue, 6>>, + IsTrue, 7>>, + IsTrue, 8>>, + IsTrue, 9>>, + IsTrue, 10>>, + IsTrue, 11>>, + IsTrue, 12>>, + IsTrue, 13>>, + IsTrue, 14>>, + IsTrue, 15>>, + IsTrue, 16>>, + IsTrue, 17>>, + IsTrue, 18>>, + IsTrue, 19>>, + IsTrue, 20>>, + IsTrue, 21>>, + IsTrue, 22>>, + IsTrue, 23>>, + IsTrue, 272>>, ] diff --git a/questions/697-extreme-tag/README.md b/questions/00697-extreme-tag/README.md similarity index 97% rename from questions/697-extreme-tag/README.md rename to questions/00697-extreme-tag/README.md index 639a712de..a01956d1f 100644 --- a/questions/697-extreme-tag/README.md +++ b/questions/00697-extreme-tag/README.md @@ -1,81 +1,81 @@

Tag extreme

by null @uid11

Take the Challenge

-Despite the structural typing system in TypeScript, it is sometimes convenient to mark some types with tags, and so that these tags do not interfere with the ability to assign values of these types to each other. - -For example, using tags, you can check that some value passes through the calls of the required functions, and in the correct order: -```ts -const doA = (x: T) => { - const result = x - - return result as Tag -} - -const doB = (x: T) => { - const result = x - - return result as Tag -}; - -const a = doA('foo') -const b = doB(a) - -type Check0 = IsTrue> -``` - -Write a function `Tag` that takes a type `B` other than `null` and `undefined` and returns a type labeled with the string literal type `T`. - -The labeled types must be mutually assignable with the corresponding original types: -```ts -declare let x: string -declare let y: Tag - -x = y = x -``` - -When tagging a type already marked with a tag, a new tag must be added to the end of the list of all tags of the type: -```ts -type T0 = Tag<{ foo: string }, 'A'> -type T1 = Tag - -type Check1 = IsTrue> -``` - -Add some functions to check for type tags. - -`GetTags` retrieves a list of all tags of a type `B`: -```ts -type T2 = Tag - -type Check2 = IsTrue, ['C']>> -``` - -`HasTag` checks if type `B` is tagged with tag `T` (and returns `true` or `false`): -```ts -type T3 = Tag<0 | 1, 'D'> - -type Check3 = IsTrue> -``` - -`HasTags` checks if type `B` is tagged in succession with tags from tuple `T`: -```ts -type T4 = Tag, 'B'>, 'C'> - -type Check4 = IsTrue> -``` - -`HasExactTags` checks if the list of all tags of type `B` is exactly equal to the `T` tuple: -```ts -type T5 = Tag, 'B'> - -type Check5 = IsTrue> -``` - -Finally, add type `UnTag`, which removes all tags from type `B`: -```ts -type T6 = Tag<{ bar: number }, 'A'> -type T7 = UnTag - -type Check6 = IsFalse> +Despite the structural typing system in TypeScript, it is sometimes convenient to mark some types with tags, and so that these tags do not interfere with the ability to assign values of these types to each other. + +For example, using tags, you can check that some value passes through the calls of the required functions, and in the correct order: +```ts +const doA = (x: T) => { + const result = x + + return result as Tag +} + +const doB = (x: T) => { + const result = x + + return result as Tag +}; + +const a = doA('foo') +const b = doB(a) + +type Check0 = IsTrue> +``` + +Write a function `Tag` that takes a type `B` other than `null` and `undefined` and returns a type labeled with the string literal type `T`. + +The labeled types must be mutually assignable with the corresponding original types: +```ts +declare let x: string +declare let y: Tag + +x = y = x +``` + +When tagging a type already marked with a tag, a new tag must be added to the end of the list of all tags of the type: +```ts +type T0 = Tag<{ foo: string }, 'A'> +type T1 = Tag + +type Check1 = IsTrue> +``` + +Add some functions to check for type tags. + +`GetTags` retrieves a list of all tags of a type `B`: +```ts +type T2 = Tag + +type Check2 = IsTrue, ['C']>> +``` + +`HasTag` checks if type `B` is tagged with tag `T` (and returns `true` or `false`): +```ts +type T3 = Tag<0 | 1, 'D'> + +type Check3 = IsTrue> +``` + +`HasTags` checks if type `B` is tagged in succession with tags from tuple `T`: +```ts +type T4 = Tag, 'B'>, 'C'> + +type Check4 = IsTrue> +``` + +`HasExactTags` checks if the list of all tags of type `B` is exactly equal to the `T` tuple: +```ts +type T5 = Tag, 'B'> + +type Check5 = IsTrue> +``` + +Finally, add type `UnTag`, which removes all tags from type `B`: +```ts +type T6 = Tag<{ bar: number }, 'A'> +type T7 = UnTag + +type Check6 = IsFalse> ``` diff --git a/questions/697-extreme-tag/info.yml b/questions/00697-extreme-tag/info.yml similarity index 100% rename from questions/697-extreme-tag/info.yml rename to questions/00697-extreme-tag/info.yml diff --git a/questions/697-extreme-tag/template.ts b/questions/00697-extreme-tag/template.ts similarity index 96% rename from questions/697-extreme-tag/template.ts rename to questions/00697-extreme-tag/template.ts index eaca7e71a..f535f5905 100644 --- a/questions/697-extreme-tag/template.ts +++ b/questions/00697-extreme-tag/template.ts @@ -1,9 +1,9 @@ -type GetTags = any - -type Tag = any - -type UnTag = any - -type HasTag = any -type HasTags = any +type GetTags = any + +type Tag = any + +type UnTag = any + +type HasTag = any +type HasTags = any type HasExactTags = any diff --git a/questions/697-extreme-tag/test-cases.ts b/questions/00697-extreme-tag/test-cases.ts similarity index 97% rename from questions/697-extreme-tag/test-cases.ts rename to questions/00697-extreme-tag/test-cases.ts index b8a01a719..76344c567 100644 --- a/questions/697-extreme-tag/test-cases.ts +++ b/questions/00697-extreme-tag/test-cases.ts @@ -1,161 +1,161 @@ -import type { Equal, Expect, IsTrue } from '@type-challenges/utils' - -/** - * Tests of assignable of tagged variables. - */ -interface I { - foo: string -} - -declare let x0: I -declare let x1: Tag -declare let x2: Tag -declare let x3: Tag, 'b'> -declare let x4: Tag, 'a'> -declare let x5: Tag, 'a'> -declare let x6: Tag, 'b'> -declare let x7: UnTag, 'b'>> - -x0 = x1 = x0 = x2 = x0 = x3 = x0 = x4 = x0 = x5 = x0 = x6 = x0 = x7 = x0 -x1 = x2 = x1 = x3 = x1 = x4 = x1 = x5 = x1 = x6 = x1 = x7 = x1 -x2 = x3 = x2 = x4 = x2 = x5 = x2 = x6 = x2 = x6 = x2 -x3 = x4 = x4 = x5 = x3 = x6 = x3 = x7 = x3 -x4 = x5 = x5 = x6 = x4 = x7 = x4 -x5 = x6 = x5 = x7 = x5 -x6 = x7 = x6 - -declare let y0: string -declare let y1: Tag -declare let y2: Tag -declare let y3: Tag, 'b'> -declare let y4: Tag, 'a'> -declare let y5: Tag, 'a'> -declare let y6: Tag, 'b'> -declare let y7: UnTag, 'b'>> - -y0 = y1 = y0 = y2 = y0 = y3 = y0 = y4 = y0 = y5 = y0 = y6 = y0 = y7 = y0 -y1 = y2 = y1 = y3 = y1 = y4 = y1 = y5 = y1 = y6 = y1 = y7 = y1 -y2 = y3 = y2 = y4 = y2 = y5 = y2 = y6 = y2 = y7 = y2 -y3 = y4 = y4 = y5 = y3 = y6 = y3 = y7 = y3 -y4 = y5 = y5 = y6 = y4 = y7 = y4 -y5 = y6 = y5 = y7 = y5 -y6 = y7 = y6 - -// @ts-expect-error -x0 = y0 -// @ts-expect-error -x1 = y1 -// @ts-expect-error -x2 = y2 -// @ts-expect-error -x3 = y3 -// @ts-expect-error -x4 = y4 -// @ts-expect-error -x5 = y5 -// @ts-expect-error -x6 = y6 -// @ts-expect-error -x7 = y7 - -declare const UNIQUE_SYMBOL: unique symbol -type US = typeof UNIQUE_SYMBOL - -/** - * Tests of API (Tag, GetTags, Untag, HasTag, HasTags, HasExactTags). - */ -type cases = [ - /** - * Tag. - */ - IsTrue, null>>, - IsTrue, undefined>>, - IsTrue & string>>, - - /** - * GetTags. - */ - IsTrue, []>>, - IsTrue, []>>, - IsTrue, []>>, - IsTrue>, ['foo']>>, - IsTrue>, ['foo']>>, - IsTrue | 1>, []>>, - IsTrue | Tag<1, 'foo'>>, ['foo']>>, - IsTrue>, ['foo']>>, - IsTrue>, ['foo']>>, - IsTrue, 'bar'>>, ['foo', 'bar']>>, - IsTrue< - Equal< - GetTags, 'bar'>, 'baz'>>, - ['foo', 'bar', 'baz'] - > - >, - - /** - * UnTag. - */ - IsTrue, null>>, - IsTrue, undefined>>, - IsTrue>, {}>>, - IsTrue, 'bar'>>, { x: 0 }>>, - IsTrue, 'bar'>>, keyof number>>, - - /** - * HasTag. - */ - Expect, false>>, - Expect, false>>, - Expect, 'foo'>, true>>, - Expect | {}, 'foo'>, false>>, - Expect, 'foo'>, true>>, - Expect | Tag<1, 'foo'>, 'foo'>, true>>, - Expect | Tag<1, 'bar'>, 'foo'>, false>>, - Expect, 'bar'>, 'foo'>, true>>, - Expect, 'foo'>, 'foo'>, true>>, - Expect, 'baz'>, 'foo'>, false>>, - Expect, 'foo'>, true>>, - Expect, 'foo'>, false>>, - Expect, 'bar'>, 'bar'>, false>>, - Expect, 'bar'>, 'foo'>, true>>, - Expect, 'foo'>, 'foo'>, true>>, - Expect, 'foo'>, true>>, - Expect, 'bar'>, false>>, - Expect, false>>, - - /** - * HasTags. - */ - Expect, false>>, - Expect, false>>, - Expect, ['foo']>, false>>, - Expect, ['foo']>, false>>, - Expect, ['foo']>, true>>, - Expect, ['foo']>, true>>, - Expect, ['foo']>, true>>, - Expect, 'bar'>, ['foo', 'bar']>, true>>, - Expect, 'bar'>, ['foo', 'bar']>, true>>, - Expect, 'foo'>, ['foo', 'bar']>, false>>, - Expect, 'foo'>, 'bar'>, ['foo', 'bar']>, true>>, - Expect, 'foo'>, 'bar'>, ['foo', 'bar']>, true>>, - Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, true>>, - Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, true>>, - Expect, 'baz'>, 'bar'>, ['foo', 'bar']>, false>>, - Expect, 'bar'>, ['foo', 'bar']>, true>>, - - /** - * HasExactTags. - */ - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, ['foo']>, true>>, - Expect, ['bar']>, false>>, - Expect, 'bar'>, ['foo', 'bar']>, true>>, - Expect, ['foo']>, true>>, - Expect, ['foo']>, true>>, - Expect, ['bar']>, false>>, - Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, false>>, - Expect, 'bar'>, 'baz'>, ['foo', 'bar', 'baz']>, true>>, - Expect, 'bar'>, ['foo', 'bar']>, true>>, -] +import type { Equal, Expect, IsTrue } from '@type-challenges/utils' + +/** + * Tests of assignable of tagged variables. + */ +interface I { + foo: string +} + +declare let x0: I +declare let x1: Tag +declare let x2: Tag +declare let x3: Tag, 'b'> +declare let x4: Tag, 'a'> +declare let x5: Tag, 'a'> +declare let x6: Tag, 'b'> +declare let x7: UnTag, 'b'>> + +x0 = x1 = x0 = x2 = x0 = x3 = x0 = x4 = x0 = x5 = x0 = x6 = x0 = x7 = x0 +x1 = x2 = x1 = x3 = x1 = x4 = x1 = x5 = x1 = x6 = x1 = x7 = x1 +x2 = x3 = x2 = x4 = x2 = x5 = x2 = x6 = x2 = x6 = x2 +x3 = x4 = x4 = x5 = x3 = x6 = x3 = x7 = x3 +x4 = x5 = x5 = x6 = x4 = x7 = x4 +x5 = x6 = x5 = x7 = x5 +x6 = x7 = x6 + +declare let y0: string +declare let y1: Tag +declare let y2: Tag +declare let y3: Tag, 'b'> +declare let y4: Tag, 'a'> +declare let y5: Tag, 'a'> +declare let y6: Tag, 'b'> +declare let y7: UnTag, 'b'>> + +y0 = y1 = y0 = y2 = y0 = y3 = y0 = y4 = y0 = y5 = y0 = y6 = y0 = y7 = y0 +y1 = y2 = y1 = y3 = y1 = y4 = y1 = y5 = y1 = y6 = y1 = y7 = y1 +y2 = y3 = y2 = y4 = y2 = y5 = y2 = y6 = y2 = y7 = y2 +y3 = y4 = y4 = y5 = y3 = y6 = y3 = y7 = y3 +y4 = y5 = y5 = y6 = y4 = y7 = y4 +y5 = y6 = y5 = y7 = y5 +y6 = y7 = y6 + +// @ts-expect-error +x0 = y0 +// @ts-expect-error +x1 = y1 +// @ts-expect-error +x2 = y2 +// @ts-expect-error +x3 = y3 +// @ts-expect-error +x4 = y4 +// @ts-expect-error +x5 = y5 +// @ts-expect-error +x6 = y6 +// @ts-expect-error +x7 = y7 + +declare const UNIQUE_SYMBOL: unique symbol +type US = typeof UNIQUE_SYMBOL + +/** + * Tests of API (Tag, GetTags, Untag, HasTag, HasTags, HasExactTags). + */ +type cases = [ + /** + * Tag. + */ + IsTrue, null>>, + IsTrue, undefined>>, + IsTrue & string>>, + + /** + * GetTags. + */ + IsTrue, []>>, + IsTrue, []>>, + IsTrue, []>>, + IsTrue>, ['foo']>>, + IsTrue>, ['foo']>>, + IsTrue | 1>, []>>, + IsTrue | Tag<1, 'foo'>>, ['foo']>>, + IsTrue>, ['foo']>>, + IsTrue>, ['foo']>>, + IsTrue, 'bar'>>, ['foo', 'bar']>>, + IsTrue< + Equal< + GetTags, 'bar'>, 'baz'>>, + ['foo', 'bar', 'baz'] + > + >, + + /** + * UnTag. + */ + IsTrue, null>>, + IsTrue, undefined>>, + IsTrue>, {}>>, + IsTrue, 'bar'>>, { x: 0 }>>, + IsTrue, 'bar'>>, keyof number>>, + + /** + * HasTag. + */ + Expect, false>>, + Expect, false>>, + Expect, 'foo'>, true>>, + Expect | {}, 'foo'>, false>>, + Expect, 'foo'>, true>>, + Expect | Tag<1, 'foo'>, 'foo'>, true>>, + Expect | Tag<1, 'bar'>, 'foo'>, false>>, + Expect, 'bar'>, 'foo'>, true>>, + Expect, 'foo'>, 'foo'>, true>>, + Expect, 'baz'>, 'foo'>, false>>, + Expect, 'foo'>, true>>, + Expect, 'foo'>, false>>, + Expect, 'bar'>, 'bar'>, false>>, + Expect, 'bar'>, 'foo'>, true>>, + Expect, 'foo'>, 'foo'>, true>>, + Expect, 'foo'>, true>>, + Expect, 'bar'>, false>>, + Expect, false>>, + + /** + * HasTags. + */ + Expect, false>>, + Expect, false>>, + Expect, ['foo']>, false>>, + Expect, ['foo']>, false>>, + Expect, ['foo']>, true>>, + Expect, ['foo']>, true>>, + Expect, ['foo']>, true>>, + Expect, 'bar'>, ['foo', 'bar']>, true>>, + Expect, 'bar'>, ['foo', 'bar']>, true>>, + Expect, 'foo'>, ['foo', 'bar']>, false>>, + Expect, 'foo'>, 'bar'>, ['foo', 'bar']>, true>>, + Expect, 'foo'>, 'bar'>, ['foo', 'bar']>, true>>, + Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, true>>, + Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, true>>, + Expect, 'baz'>, 'bar'>, ['foo', 'bar']>, false>>, + Expect, 'bar'>, ['foo', 'bar']>, true>>, + + /** + * HasExactTags. + */ + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, ['foo']>, true>>, + Expect, ['bar']>, false>>, + Expect, 'bar'>, ['foo', 'bar']>, true>>, + Expect, ['foo']>, true>>, + Expect, ['foo']>, true>>, + Expect, ['bar']>, false>>, + Expect, 'bar'>, 'baz'>, ['foo', 'bar']>, false>>, + Expect, 'bar'>, 'baz'>, ['foo', 'bar', 'baz']>, true>>, + Expect, 'bar'>, ['foo', 'bar']>, true>>, +] diff --git a/questions/730-hard-union-to-tuple/README.md b/questions/00730-hard-union-to-tuple/README.md similarity index 66% rename from questions/730-hard-union-to-tuple/README.md rename to questions/00730-hard-union-to-tuple/README.md index a5883b7bb..52ea719c6 100644 --- a/questions/730-hard-union-to-tuple/README.md +++ b/questions/00730-hard-union-to-tuple/README.md @@ -1,33 +1,33 @@

Union to Tuple hard #union #tuple #infer

by Sg @suica

Take the Challenge

-Implement a type, `UnionToTuple`, that converts a union to a tuple. - -As we know, union is an unordered structure, but tuple is an ordered, which implies that we are not supposed to preassume any order will be preserved between terms of one union, when unions are created or transformed. - -Hence in this challenge, **any permutation of the elements in the output tuple is acceptable**. - -Your type should resolve to one of the following two types, but ***NOT*** a union of them! -```ts -UnionToTuple<1> // [1], and correct -UnionToTuple<'any' | 'a'> // ['any','a'], and correct -``` -or -```ts -UnionToTuple<'any' | 'a'> // ['a','any'], and correct -``` -It shouldn't be a union of all acceptable tuples... -```ts -UnionToTuple<'any' | 'a'> // ['a','any'] | ['any','a'], which is incorrect -``` - - -And a union could collapes, which means some types could absorb (or be absorbed by) others and there is no way to prevent this absorption. See the following examples: -```ts -Equal, UnionToTuple> // will always be a true -Equal, UnionToTuple> // will always be a true -Equal, UnionToTuple<'a'>> // will always be a true -Equal, UnionToTuple<'a'>> // will always be a true +Implement a type, `UnionToTuple`, that converts a union to a tuple. + +As we know, union is an unordered structure, but tuple is an ordered, which implies that we are not supposed to preassume any order will be preserved between terms of one union, when unions are created or transformed. + +Hence in this challenge, **any permutation of the elements in the output tuple is acceptable**. + +Your type should resolve to one of the following two types, but ***NOT*** a union of them! +```ts +UnionToTuple<1> // [1], and correct +UnionToTuple<'any' | 'a'> // ['any','a'], and correct +``` +or +```ts +UnionToTuple<'any' | 'a'> // ['a','any'], and correct +``` +It shouldn't be a union of all acceptable tuples... +```ts +UnionToTuple<'any' | 'a'> // ['a','any'] | ['any','a'], which is incorrect +``` + + +And a union could collapes, which means some types could absorb (or be absorbed by) others and there is no way to prevent this absorption. See the following examples: +```ts +Equal, UnionToTuple> // will always be a true +Equal, UnionToTuple> // will always be a true +Equal, UnionToTuple<'a'>> // will always be a true +Equal, UnionToTuple<'a'>> // will always be a true ``` -
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 55・Union to Intersection 472・Tuple to Enum Object 3188・Tuple to Nested Object \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 55・Union to Intersection 472・Tuple to Enum Object 3188・Tuple to Nested Object \ No newline at end of file diff --git a/questions/730-hard-union-to-tuple/info.yml b/questions/00730-hard-union-to-tuple/info.yml similarity index 100% rename from questions/730-hard-union-to-tuple/info.yml rename to questions/00730-hard-union-to-tuple/info.yml diff --git a/questions/730-hard-union-to-tuple/template.ts b/questions/00730-hard-union-to-tuple/template.ts similarity index 100% rename from questions/730-hard-union-to-tuple/template.ts rename to questions/00730-hard-union-to-tuple/template.ts diff --git a/questions/730-hard-union-to-tuple/test-cases.ts b/questions/00730-hard-union-to-tuple/test-cases.ts similarity index 98% rename from questions/730-hard-union-to-tuple/test-cases.ts rename to questions/00730-hard-union-to-tuple/test-cases.ts index efd42d6e8..217ccee7c 100644 --- a/questions/730-hard-union-to-tuple/test-cases.ts +++ b/questions/00730-hard-union-to-tuple/test-cases.ts @@ -1,17 +1,17 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type ExtractValuesOfTuple = T[keyof T & number] - -type cases = [ - Expect['length'], 2>>, - Expect>, 'a' | 'b'>>, - Expect>, 'a'>>, - Expect>, any>>, - Expect>, void | 1>>, - Expect>, any | 1>>, - Expect>, any>>, - Expect>, 'f' | 'd' | 1>>, - Expect>, [{ a: 1 }] | 1>>, - Expect>, never>>, - Expect>, 'f' | 'e' | 1 | 2 | 'g' | 'c' | 'd' | 'a' | 'b'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type ExtractValuesOfTuple = T[keyof T & number] + +type cases = [ + Expect['length'], 2>>, + Expect>, 'a' | 'b'>>, + Expect>, 'a'>>, + Expect>, any>>, + Expect>, void | 1>>, + Expect>, any | 1>>, + Expect>, any>>, + Expect>, 'f' | 'd' | 1>>, + Expect>, [{ a: 1 }] | 1>>, + Expect>, never>>, + Expect>, 'f' | 'e' | 1 | 2 | 'g' | 'c' | 'd' | 'a' | 'b'>>, +] diff --git a/questions/734-extreme-inclusive-range/README.md b/questions/00734-extreme-inclusive-range/README.md similarity index 99% rename from questions/734-extreme-inclusive-range/README.md rename to questions/00734-extreme-inclusive-range/README.md index 80896cc0d..c9ecf56ed 100644 --- a/questions/734-extreme-inclusive-range/README.md +++ b/questions/00734-extreme-inclusive-range/README.md @@ -1,11 +1,11 @@

Inclusive Range extreme #infer #array

by Sg @suica

Take the Challenge

-Recursion depth in type system is one of the limitations of TypeScript, the number is around 45. - -*We need to go deeper*. And we could go deeper. - -In this challenge, you are given one lower boundary and one higher boundary, by which a range of natural numbers is inclusively sliced. You should develop a technique that enables you to do recursion deeper than the limitation, since both boundary vary from 0 to 200. - +Recursion depth in type system is one of the limitations of TypeScript, the number is around 45. + +*We need to go deeper*. And we could go deeper. + +In this challenge, you are given one lower boundary and one higher boundary, by which a range of natural numbers is inclusively sliced. You should develop a technique that enables you to do recursion deeper than the limitation, since both boundary vary from 0 to 200. + Note that when `Lower > Higher`, output an empty tuple. diff --git a/questions/734-extreme-inclusive-range/info.yml b/questions/00734-extreme-inclusive-range/info.yml similarity index 100% rename from questions/734-extreme-inclusive-range/info.yml rename to questions/00734-extreme-inclusive-range/info.yml diff --git a/questions/734-extreme-inclusive-range/template.ts b/questions/00734-extreme-inclusive-range/template.ts similarity index 100% rename from questions/734-extreme-inclusive-range/template.ts rename to questions/00734-extreme-inclusive-range/template.ts diff --git a/questions/734-extreme-inclusive-range/test-cases.ts b/questions/00734-extreme-inclusive-range/test-cases.ts similarity index 99% rename from questions/734-extreme-inclusive-range/test-cases.ts rename to questions/00734-extreme-inclusive-range/test-cases.ts index aa7d58409..af74fdef2 100644 --- a/questions/734-extreme-inclusive-range/test-cases.ts +++ b/questions/00734-extreme-inclusive-range/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, []>>, - Expect, [5]>>, - Expect, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]>>, - Expect, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]>>, - Expect, [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146]>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, []>>, + Expect, [5]>>, + Expect, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]>>, + Expect, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]>>, + Expect, [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146]>>, ] diff --git a/questions/741-extreme-sort/README.md b/questions/00741-extreme-sort/README.md similarity index 98% rename from questions/741-extreme-sort/README.md rename to questions/00741-extreme-sort/README.md index 87ef9d083..ee0458d09 100644 --- a/questions/741-extreme-sort/README.md +++ b/questions/00741-extreme-sort/README.md @@ -1,23 +1,23 @@

Sort extreme #infer #array

by Sg @suica

Take the Challenge

-In this challenge, you are required to sort natural number arrays in either ascend order or descent order. - -Ascend order examples: -```ts -Sort<[]> // [] -Sort<[1]> // [1] -Sort<[2, 4, 7, 6, 6, 6, 5, 8, 9]> // [2, 4, 5, 6, 6, 6, 7, 8, 9] -``` - -The `Sort` type should also accept a boolean type. When it is `true`, the sorted result should be in descent order. Some examples: - -```ts -Sort<[3, 2, 1], true> // [3, 2, 1] -Sort<[3, 2, 0, 1, 0, 0, 0], true> // [3, 2, 1, 0, 0, 0, 0] -``` - -Extra challenges: -1. Support natural numbers with 15+ digits. +In this challenge, you are required to sort natural number arrays in either ascend order or descent order. + +Ascend order examples: +```ts +Sort<[]> // [] +Sort<[1]> // [1] +Sort<[2, 4, 7, 6, 6, 6, 5, 8, 9]> // [2, 4, 5, 6, 6, 6, 7, 8, 9] +``` + +The `Sort` type should also accept a boolean type. When it is `true`, the sorted result should be in descent order. Some examples: + +```ts +Sort<[3, 2, 1], true> // [3, 2, 1] +Sort<[3, 2, 0, 1, 0, 0, 0], true> // [3, 2, 1, 0, 0, 0, 0] +``` + +Extra challenges: +1. Support natural numbers with 15+ digits. 2. Support float numbers. diff --git a/questions/741-extreme-sort/info.yml b/questions/00741-extreme-sort/info.yml similarity index 100% rename from questions/741-extreme-sort/info.yml rename to questions/00741-extreme-sort/info.yml diff --git a/questions/741-extreme-sort/template.ts b/questions/00741-extreme-sort/template.ts similarity index 100% rename from questions/741-extreme-sort/template.ts rename to questions/00741-extreme-sort/template.ts diff --git a/questions/741-extreme-sort/test-cases.ts b/questions/00741-extreme-sort/test-cases.ts similarity index 98% rename from questions/741-extreme-sort/test-cases.ts rename to questions/00741-extreme-sort/test-cases.ts index 4405b38b1..26c0eb51f 100644 --- a/questions/741-extreme-sort/test-cases.ts +++ b/questions/00741-extreme-sort/test-cases.ts @@ -1,23 +1,23 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [1]>>, - Expect, [1, 2]>>, - Expect, [0, 0, 0]>>, - Expect, [1, 2, 3]>>, - Expect, [1, 2, 3]>>, - Expect, [1, 2, 2, 3]>>, - Expect, [0, 0, 0, 0, 1, 2, 3]>>, - Expect, [2, 4, 5, 6, 6, 6, 7, 8, 9]>>, - Expect, [1, 1, 1, 1, 1, 1, 1, 1, 2]>>, - Expect, []>>, - Expect, [1]>>, - Expect, [2, 1]>>, - Expect, [0, 0, 0]>>, - Expect, [3, 2, 1]>>, - Expect, [3, 2, 1]>>, - Expect, [3, 2, 2, 1]>>, - Expect, [3, 2, 1, 0, 0, 0, 0]>>, - Expect, [9, 8, 7, 6, 6, 6, 5, 4, 2]>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [1]>>, + Expect, [1, 2]>>, + Expect, [0, 0, 0]>>, + Expect, [1, 2, 3]>>, + Expect, [1, 2, 3]>>, + Expect, [1, 2, 2, 3]>>, + Expect, [0, 0, 0, 0, 1, 2, 3]>>, + Expect, [2, 4, 5, 6, 6, 6, 7, 8, 9]>>, + Expect, [1, 1, 1, 1, 1, 1, 1, 1, 2]>>, + Expect, []>>, + Expect, [1]>>, + Expect, [2, 1]>>, + Expect, [0, 0, 0]>>, + Expect, [3, 2, 1]>>, + Expect, [3, 2, 1]>>, + Expect, [3, 2, 2, 1]>>, + Expect, [3, 2, 1, 0, 0, 0, 0]>>, + Expect, [9, 8, 7, 6, 6, 6, 5, 4, 2]>>, ] diff --git a/questions/847-hard-string-join/README.md b/questions/00847-hard-string-join/README.md similarity index 98% rename from questions/847-hard-string-join/README.md rename to questions/00847-hard-string-join/README.md index 0219e1d5c..9bd60ad3c 100644 --- a/questions/847-hard-string-join/README.md +++ b/questions/00847-hard-string-join/README.md @@ -1,25 +1,25 @@

String Join hard

by Matt Davis @tl-matt-davis

Take the Challenge

-Create a type-safe string join utility which can be used like so: - -```ts -const hyphenJoiner = join('-') -const result = hyphenJoiner('a', 'b', 'c'); // = 'a-b-c' -``` - -Or alternatively: -```ts -join('#')('a', 'b', 'c') // = 'a#b#c' -``` - -When we pass an empty delimiter (i.e '') to join, we should concat the strings as they are, i.e: -```ts -join('')('a', 'b', 'c') // = 'abc' -``` - -When only one item is passed, we should get back the original item (without any delimiter added): -```ts -join('-')('a') // = 'a' +Create a type-safe string join utility which can be used like so: + +```ts +const hyphenJoiner = join('-') +const result = hyphenJoiner('a', 'b', 'c'); // = 'a-b-c' +``` + +Or alternatively: +```ts +join('#')('a', 'b', 'c') // = 'a#b#c' +``` + +When we pass an empty delimiter (i.e '') to join, we should concat the strings as they are, i.e: +```ts +join('')('a', 'b', 'c') // = 'abc' +``` + +When only one item is passed, we should get back the original item (without any delimiter added): +```ts +join('-')('a') // = 'a' ``` diff --git a/questions/847-hard-string-join/info.yml b/questions/00847-hard-string-join/info.yml similarity index 100% rename from questions/847-hard-string-join/info.yml rename to questions/00847-hard-string-join/info.yml diff --git a/questions/847-hard-string-join/template.ts b/questions/00847-hard-string-join/template.ts similarity index 100% rename from questions/847-hard-string-join/template.ts rename to questions/00847-hard-string-join/template.ts diff --git a/questions/847-hard-string-join/test-cases.ts b/questions/00847-hard-string-join/test-cases.ts similarity index 97% rename from questions/847-hard-string-join/test-cases.ts rename to questions/00847-hard-string-join/test-cases.ts index 543061421..16e47fbea 100644 --- a/questions/847-hard-string-join/test-cases.ts +++ b/questions/00847-hard-string-join/test-cases.ts @@ -1,22 +1,22 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -// Edge cases -const noCharsOutput = join('-')() -const oneCharOutput = join('-')('a') -const noDelimiterOutput = join('')('a', 'b', 'c') - -// Regular cases -const hyphenOutput = join('-')('a', 'b', 'c') -const hashOutput = join('#')('a', 'b', 'c') -const twoCharOutput = join('-')('a', 'b') -const longOutput = join('-')('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') - -type cases = [ - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, +import type { Equal, Expect } from '@type-challenges/utils' + +// Edge cases +const noCharsOutput = join('-')() +const oneCharOutput = join('-')('a') +const noDelimiterOutput = join('')('a', 'b', 'c') + +// Regular cases +const hyphenOutput = join('-')('a', 'b', 'c') +const hashOutput = join('#')('a', 'b', 'c') +const twoCharOutput = join('-')('a', 'b') +const longOutput = join('-')('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') + +type cases = [ + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, ] diff --git a/questions/869-extreme-distributeunions/README.md b/questions/00869-extreme-distributeunions/README.md similarity index 98% rename from questions/869-extreme-distributeunions/README.md rename to questions/00869-extreme-distributeunions/README.md index 2a7c5dcbd..9813b9dcf 100644 --- a/questions/869-extreme-distributeunions/README.md +++ b/questions/00869-extreme-distributeunions/README.md @@ -1,37 +1,37 @@

DistributeUnions extreme

by Gabriel Vergnaud @gvergnaud

Take the Challenge

-Implement a type `Distribute Unions`, that turns a type of data structure containing union types into a union of -all possible types of permitted data structures that don't contain any union. The data structure can be any -combination of objects and tuples on any level of nesting. - -For example: - -```ts -type T1 = DistributeUnions<[1 | 2, 'a' | 'b']> -// => [1, 'a'] | [2, 'a'] | [1, 'b'] | [2, 'b'] - -type T2 = DistributeUnions<{ type: 'a', value: number | string } | { type: 'b', value: boolean }> -// => | { type 'a', value: number } -// | { type 'a', value: string } -// | { type 'b', value: boolean } - -type T3 = DistributeUnions<[{ value: 'a' | 'b' }, { x: { y: 2 | 3 } }] | 17> -// => | [{ value: 'a' }, { x: { y: 2 } }] -// | [{ value: 'a' }, { x: { y: 3 } }] -// | [{ value: 'b' }, { x: { y: 2 } }] -// | [{ value: 'b' }, { x: { y: 3 } }] -// | 17 -``` - -For context, this type can be very useful if you want to exclude a case on deep data structures: - -```ts -type ExcludeDeep = Exclude, B> - -type T0 = ExcludeDeep<[{ value: 'a' | 'b' }, { x: { y: 2 | 3 } }] | 17, [{ value: 'a' }, any]> -// => | [{ value: 'b' }, { x: { y: 2 } }] -// | [{ value: 'b' }, { x: { y: 3 } }] -// | 17 +Implement a type `Distribute Unions`, that turns a type of data structure containing union types into a union of +all possible types of permitted data structures that don't contain any union. The data structure can be any +combination of objects and tuples on any level of nesting. + +For example: + +```ts +type T1 = DistributeUnions<[1 | 2, 'a' | 'b']> +// => [1, 'a'] | [2, 'a'] | [1, 'b'] | [2, 'b'] + +type T2 = DistributeUnions<{ type: 'a', value: number | string } | { type: 'b', value: boolean }> +// => | { type 'a', value: number } +// | { type 'a', value: string } +// | { type 'b', value: boolean } + +type T3 = DistributeUnions<[{ value: 'a' | 'b' }, { x: { y: 2 | 3 } }] | 17> +// => | [{ value: 'a' }, { x: { y: 2 } }] +// | [{ value: 'a' }, { x: { y: 3 } }] +// | [{ value: 'b' }, { x: { y: 2 } }] +// | [{ value: 'b' }, { x: { y: 3 } }] +// | 17 +``` + +For context, this type can be very useful if you want to exclude a case on deep data structures: + +```ts +type ExcludeDeep = Exclude, B> + +type T0 = ExcludeDeep<[{ value: 'a' | 'b' }, { x: { y: 2 | 3 } }] | 17, [{ value: 'a' }, any]> +// => | [{ value: 'b' }, { x: { y: 2 } }] +// | [{ value: 'b' }, { x: { y: 3 } }] +// | 17 ``` diff --git a/questions/869-extreme-distributeunions/info.yml b/questions/00869-extreme-distributeunions/info.yml similarity index 100% rename from questions/869-extreme-distributeunions/info.yml rename to questions/00869-extreme-distributeunions/info.yml diff --git a/questions/869-extreme-distributeunions/template.ts b/questions/00869-extreme-distributeunions/template.ts similarity index 100% rename from questions/869-extreme-distributeunions/template.ts rename to questions/00869-extreme-distributeunions/template.ts diff --git a/questions/869-extreme-distributeunions/test-cases.ts b/questions/00869-extreme-distributeunions/test-cases.ts similarity index 96% rename from questions/869-extreme-distributeunions/test-cases.ts rename to questions/00869-extreme-distributeunions/test-cases.ts index e19da70bf..86a7b130a 100644 --- a/questions/869-extreme-distributeunions/test-cases.ts +++ b/questions/00869-extreme-distributeunions/test-cases.ts @@ -1,82 +1,82 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - // Already distributed unions should stay the same: - Expect, 1>>, - Expect, string>>, - Expect, 1 | 2>>, - Expect, 'b' | { type: 'a' } | [1]>>, - // tuples: - Expect, [1, 3] | [2, 3]>>, - Expect, [1, 'a'] | [1, 'b'] | [2, 'a'] | [2, 'b']>>, - Expect< - Equal< - DistributeUnions<[1 | 2, 'a' | 'b', false | true]>, - | [1, 'a', false] - | [1, 'a', true] - | [1, 'b', false] - | [1, 'b', true] - | [2, 'a', false] - | [2, 'a', true] - | [2, 'b', false] - | [2, 'b', true] - > - >, - // objects - Expect< - Equal< - DistributeUnions<{ x: 'a' | 'b'; y: 'c' | 'd' }>, - { x: 'a'; y: 'c' } | { x: 'a'; y: 'd' } | { x: 'b'; y: 'c' } | { x: 'b'; y: 'd' } - > - >, - Expect< - Equal< - DistributeUnions<{ type: 'a'; value: number | string } | { type: 'b'; value: boolean }>, - | { type: 'a'; value: string } - | { type: 'a'; value: number } - | { type: 'b'; value: false } - | { type: 'b'; value: true } - > - >, - Expect< - Equal< - DistributeUnions< - | { - type: 'a' - option: { kind: 'none' } | { kind: 'some'; value: 'x' | 'y' } - } - | { type: 'b'; msg: string } - >, - | { type: 'b'; msg: string } - | { type: 'a'; option: { kind: 'none' } } - | { type: 'a'; option: { kind: 'some'; value: 'x' } } - | { type: 'a'; option: { kind: 'some'; value: 'y' } } - > - >, - // mixed structures: - Expect< - Equal< - DistributeUnions<[false | true, { value: 'a' | 'b' }, { x: { y: 2 | 3 } }]>, - | [false, { value: 'a' }, { x: { y: 2 } }] - | [false, { value: 'a' }, { x: { y: 3 } }] - | [false, { value: 'b' }, { x: { y: 2 } }] - | [false, { value: 'b' }, { x: { y: 3 } }] - | [true, { value: 'a' }, { x: { y: 2 } }] - | [true, { value: 'a' }, { x: { y: 3 } }] - | [true, { value: 'b' }, { x: { y: 2 } }] - | [true, { value: 'b' }, { x: { y: 3 } }] - > - >, - Expect< - Equal< - DistributeUnions<17 | [10 | { value: 'a' | 'b' }, { x: { y: 2 | 3 } }]>, - | 17 - | [10, { x: { y: 2 } }] - | [10, { x: { y: 3 } }] - | [{ value: 'a' }, { x: { y: 2 } }] - | [{ value: 'a' }, { x: { y: 3 } }] - | [{ value: 'b' }, { x: { y: 2 } }] - | [{ value: 'b' }, { x: { y: 3 } }] - > - >, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + // Already distributed unions should stay the same: + Expect, 1>>, + Expect, string>>, + Expect, 1 | 2>>, + Expect, 'b' | { type: 'a' } | [1]>>, + // tuples: + Expect, [1, 3] | [2, 3]>>, + Expect, [1, 'a'] | [1, 'b'] | [2, 'a'] | [2, 'b']>>, + Expect< + Equal< + DistributeUnions<[1 | 2, 'a' | 'b', false | true]>, + | [1, 'a', false] + | [1, 'a', true] + | [1, 'b', false] + | [1, 'b', true] + | [2, 'a', false] + | [2, 'a', true] + | [2, 'b', false] + | [2, 'b', true] + > + >, + // objects + Expect< + Equal< + DistributeUnions<{ x: 'a' | 'b'; y: 'c' | 'd' }>, + { x: 'a'; y: 'c' } | { x: 'a'; y: 'd' } | { x: 'b'; y: 'c' } | { x: 'b'; y: 'd' } + > + >, + Expect< + Equal< + DistributeUnions<{ type: 'a'; value: number | string } | { type: 'b'; value: boolean }>, + | { type: 'a'; value: string } + | { type: 'a'; value: number } + | { type: 'b'; value: false } + | { type: 'b'; value: true } + > + >, + Expect< + Equal< + DistributeUnions< + | { + type: 'a' + option: { kind: 'none' } | { kind: 'some'; value: 'x' | 'y' } + } + | { type: 'b'; msg: string } + >, + | { type: 'b'; msg: string } + | { type: 'a'; option: { kind: 'none' } } + | { type: 'a'; option: { kind: 'some'; value: 'x' } } + | { type: 'a'; option: { kind: 'some'; value: 'y' } } + > + >, + // mixed structures: + Expect< + Equal< + DistributeUnions<[false | true, { value: 'a' | 'b' }, { x: { y: 2 | 3 } }]>, + | [false, { value: 'a' }, { x: { y: 2 } }] + | [false, { value: 'a' }, { x: { y: 3 } }] + | [false, { value: 'b' }, { x: { y: 2 } }] + | [false, { value: 'b' }, { x: { y: 3 } }] + | [true, { value: 'a' }, { x: { y: 2 } }] + | [true, { value: 'a' }, { x: { y: 3 } }] + | [true, { value: 'b' }, { x: { y: 2 } }] + | [true, { value: 'b' }, { x: { y: 3 } }] + > + >, + Expect< + Equal< + DistributeUnions<17 | [10 | { value: 'a' | 'b' }, { x: { y: 2 | 3 } }]>, + | 17 + | [10, { x: { y: 2 } }] + | [10, { x: { y: 3 } }] + | [{ value: 'a' }, { x: { y: 2 } }] + | [{ value: 'a' }, { x: { y: 3 } }] + | [{ value: 'b' }, { x: { y: 2 } }] + | [{ value: 'b' }, { x: { y: 3 } }] + > + >, +] diff --git a/questions/898-easy-includes/README.ja.md b/questions/00898-easy-includes/README.ja.md similarity index 100% rename from questions/898-easy-includes/README.ja.md rename to questions/00898-easy-includes/README.ja.md diff --git a/questions/898-easy-includes/README.ko.md b/questions/00898-easy-includes/README.ko.md similarity index 100% rename from questions/898-easy-includes/README.ko.md rename to questions/00898-easy-includes/README.ko.md diff --git a/questions/898-easy-includes/README.md b/questions/00898-easy-includes/README.md similarity index 100% rename from questions/898-easy-includes/README.md rename to questions/00898-easy-includes/README.md diff --git a/questions/898-easy-includes/README.zh-CN.md b/questions/00898-easy-includes/README.zh-CN.md similarity index 100% rename from questions/898-easy-includes/README.zh-CN.md rename to questions/00898-easy-includes/README.zh-CN.md diff --git a/questions/898-easy-includes/info.yml b/questions/00898-easy-includes/info.yml similarity index 100% rename from questions/898-easy-includes/info.yml rename to questions/00898-easy-includes/info.yml diff --git a/questions/898-easy-includes/template.ts b/questions/00898-easy-includes/template.ts similarity index 100% rename from questions/898-easy-includes/template.ts rename to questions/00898-easy-includes/template.ts diff --git a/questions/898-easy-includes/test-cases.ts b/questions/00898-easy-includes/test-cases.ts similarity index 98% rename from questions/898-easy-includes/test-cases.ts rename to questions/00898-easy-includes/test-cases.ts index f6e02a466..3cbe8a638 100644 --- a/questions/898-easy-includes/test-cases.ts +++ b/questions/00898-easy-includes/test-cases.ts @@ -1,20 +1,20 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, false>>, - Expect, true>>, - Expect, false>>, - Expect, true>>, - Expect, true>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, true>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, false>>, + Expect, true>>, + Expect, false>>, + Expect, true>>, + Expect, true>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, true>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, +] diff --git a/questions/925-extreme-assert-array-index/README.md b/questions/00925-extreme-assert-array-index/README.md similarity index 97% rename from questions/925-extreme-assert-array-index/README.md rename to questions/00925-extreme-assert-array-index/README.md index b1db94895..f05a55517 100644 --- a/questions/925-extreme-assert-array-index/README.md +++ b/questions/00925-extreme-assert-array-index/README.md @@ -1,95 +1,95 @@ -

Assert Array Index extreme #array

by null @uid11

Take the Challenge

- -Sometimes we want to use the good old `for`-loop with an index to traverse the array, but in this case TypeScript does not check in any way that we are accessing the elements of the array at its real index (not exceeding the length of the array), and that we are not using an arbitrary number as an index, or index from another array (for nested loops, for traversing matrices or graphs): -```ts -const matrix = [ - [3, 4], - [5, 6], - [7, 8], -]; - -// This example contains no type errors when the noUncheckedIndexedAccess option is off. -for (let i = 0; i < matrix.length; i += 1) { - const columns: number[] = matrix[i]; - - for (let j = 0; j < columns.length; j += 1) { - const current: number = columns[i]; // oops! i instead of j - - console.log( - current.toFixed(), // TypeError: Cannot read property 'toFixed' of undefined - ); - } -} -``` - -You can enable the [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) option (in `tsconfig.json`), but then each time you access an array element, you will need to check that this element exists, which is somewhat verbose and inconvenient, especially since in the case of such a `for`-traversal, we are sure that the index does not exceed the length of the array: -```ts -const numbers = [5, 7]; - -for (let i = 0; i < numbers.length; i += 1) { - const current = numbers[i]; - - if (current !== undefined) { - console.log(current.toFixed()); - } -} -``` - -Write an `assert`-function `assertArrayIndex(array, key)` that can be applied to any `array` (with an arbitrary unique string `key`, which is needed to distinguish arrays at the type level) to allow access to the elements of this array only by the index obtained from array by the special generic type `Index` (this functionality requires enabling the [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) option in `tsconfig.json`): -```ts -const numbers = [5, 7]; - -assertArrayIndex(numbers, 'numbers'); - -for (let i = 0 as Index; i < numbers.length; i += 1) { - console.log(numbers[i].toFixed()); -} -``` - -When accessing by such an index, it must be guaranteed that an element in the array exists, and when accessing an array by any other indices, there is no such guarantee (the element may not exist): -```ts -const matrix = [ - [3, 4], - [5, 6], - [7, 8], -]; - -assertArrayIndex(matrix, 'rows'); - -let sum = 0; - -for (let i = 0 as Index; i < matrix.length; i += 1) { - const columns: number[] = matrix[i]; - - // @ts-expect-error: number | undefined in not assignable to number - const x: number[] = matrix[0]; - - assertArrayIndex(columns, 'columns'); - - for (let j = 0 as Index; j < columns.length; j += 1) { - sum += columns[j]; - - // @ts-expect-error: number | undefined in not assignable to number - const y: number = columns[i]; - - // @ts-expect-error: number | undefined in not assignable to number - const z: number = columns[0]; - - // @ts-expect-error: number[] | undefined in not assignable to number[] - const u: number[] = matrix[j]; - } -} -``` - -The `assertArrayIndex` function cannot be called on tuples (since the accessing the elements is already well typed in them): -```ts -const tuple = [5, 7] as const; - -// @ts-expect-error -assertArrayIndex(tuple, 'tuple'); -``` - -(Additional design considerations for the proposed API: [#925](https://github.com/type-challenges/type-challenges/issues/925#issuecomment-780889329).) - - -
Back Share your Solutions Check out Solutions +

Assert Array Index extreme #array

by null @uid11

Take the Challenge

+ +Sometimes we want to use the good old `for`-loop with an index to traverse the array, but in this case TypeScript does not check in any way that we are accessing the elements of the array at its real index (not exceeding the length of the array), and that we are not using an arbitrary number as an index, or index from another array (for nested loops, for traversing matrices or graphs): +```ts +const matrix = [ + [3, 4], + [5, 6], + [7, 8], +]; + +// This example contains no type errors when the noUncheckedIndexedAccess option is off. +for (let i = 0; i < matrix.length; i += 1) { + const columns: number[] = matrix[i]; + + for (let j = 0; j < columns.length; j += 1) { + const current: number = columns[i]; // oops! i instead of j + + console.log( + current.toFixed(), // TypeError: Cannot read property 'toFixed' of undefined + ); + } +} +``` + +You can enable the [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) option (in `tsconfig.json`), but then each time you access an array element, you will need to check that this element exists, which is somewhat verbose and inconvenient, especially since in the case of such a `for`-traversal, we are sure that the index does not exceed the length of the array: +```ts +const numbers = [5, 7]; + +for (let i = 0; i < numbers.length; i += 1) { + const current = numbers[i]; + + if (current !== undefined) { + console.log(current.toFixed()); + } +} +``` + +Write an `assert`-function `assertArrayIndex(array, key)` that can be applied to any `array` (with an arbitrary unique string `key`, which is needed to distinguish arrays at the type level) to allow access to the elements of this array only by the index obtained from array by the special generic type `Index` (this functionality requires enabling the [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) option in `tsconfig.json`): +```ts +const numbers = [5, 7]; + +assertArrayIndex(numbers, 'numbers'); + +for (let i = 0 as Index; i < numbers.length; i += 1) { + console.log(numbers[i].toFixed()); +} +``` + +When accessing by such an index, it must be guaranteed that an element in the array exists, and when accessing an array by any other indices, there is no such guarantee (the element may not exist): +```ts +const matrix = [ + [3, 4], + [5, 6], + [7, 8], +]; + +assertArrayIndex(matrix, 'rows'); + +let sum = 0; + +for (let i = 0 as Index; i < matrix.length; i += 1) { + const columns: number[] = matrix[i]; + + // @ts-expect-error: number | undefined in not assignable to number + const x: number[] = matrix[0]; + + assertArrayIndex(columns, 'columns'); + + for (let j = 0 as Index; j < columns.length; j += 1) { + sum += columns[j]; + + // @ts-expect-error: number | undefined in not assignable to number + const y: number = columns[i]; + + // @ts-expect-error: number | undefined in not assignable to number + const z: number = columns[0]; + + // @ts-expect-error: number[] | undefined in not assignable to number[] + const u: number[] = matrix[j]; + } +} +``` + +The `assertArrayIndex` function cannot be called on tuples (since the accessing the elements is already well typed in them): +```ts +const tuple = [5, 7] as const; + +// @ts-expect-error +assertArrayIndex(tuple, 'tuple'); +``` + +(Additional design considerations for the proposed API: [#925](https://github.com/type-challenges/type-challenges/issues/925#issuecomment-780889329).) + + +
Back Share your Solutions Check out Solutions diff --git a/questions/925-extreme-assert-array-index/info.yml b/questions/00925-extreme-assert-array-index/info.yml similarity index 100% rename from questions/925-extreme-assert-array-index/info.yml rename to questions/00925-extreme-assert-array-index/info.yml diff --git a/questions/925-extreme-assert-array-index/template.ts b/questions/00925-extreme-assert-array-index/template.ts similarity index 97% rename from questions/925-extreme-assert-array-index/template.ts rename to questions/00925-extreme-assert-array-index/template.ts index f414dd019..733a257cf 100644 --- a/questions/925-extreme-assert-array-index/template.ts +++ b/questions/00925-extreme-assert-array-index/template.ts @@ -1,3 +1,3 @@ -function assertArrayIndex(array: readonly unknown[], key: string) {} - +function assertArrayIndex(array: readonly unknown[], key: string) {} + type Index = any diff --git a/questions/925-extreme-assert-array-index/test-cases.ts b/questions/00925-extreme-assert-array-index/test-cases.ts similarity index 95% rename from questions/925-extreme-assert-array-index/test-cases.ts rename to questions/00925-extreme-assert-array-index/test-cases.ts index bd0a9608e..25a35279f 100644 --- a/questions/925-extreme-assert-array-index/test-cases.ts +++ b/questions/00925-extreme-assert-array-index/test-cases.ts @@ -1,100 +1,100 @@ -const matrix = [ - [3, 4], - [5, 6], - [7, 8], -] - -assertArrayIndex(matrix, 'rows') - -let sum = 0 - -for (let i = 0 as Index; i < matrix.length; i += 1) { - const columns: number[] = matrix[i] - - // @ts-expect-error: number | undefined in not assignable to number - const x: number[] = matrix[0] - - assertArrayIndex(columns, 'columns') - - for (let j = 0 as Index; j < columns.length; j += 1) { - sum += columns[j] - - // @ts-expect-error: number | undefined in not assignable to number - const y: number = columns[i] - - // @ts-expect-error: number | undefined in not assignable to number - const z: number = columns[0] - - // @ts-expect-error: number[] | undefined in not assignable to number[] - const u: number[] = matrix[j] - } -} - -const a: string[] = [] - -assertArrayIndex(a, 'a') - -for (let p = 0 as Index; p < a.length; p += 1) { - const value: string = a[p] - - // @ts-expect-error: string | undefined is not assignable to string - const z: string = a[2] -} - -a.push('qux') -// @ts-expect-error: number is not assignable to string -a.push(3) - -for (const value of a) { - const other: string = value -} - -const b: number[] = [] - -assertArrayIndex(b, 'b') - -for (let p = 0 as Index; p < b.length; p += 1) { - // @ts-expect-error: number | undefined is not assignable to string - const value: string = b[p] -} - -const c: string[] = [] - -assertArrayIndex(c, 'c') - -for (let p = 0; p < c.length; p += 1) { - // @ts-expect-error: string | undefined is not assignable to string - let value: string = c[p] - - // @ts-expect-error: string | undefined is not assignable to string - value = c[0 as Index] -} - -const d: readonly number[] = [] - -assertArrayIndex(d, 'd') - -for (let p = 0 as Index; p < d.length; p += 1) { - const value: number = d[p] - - // @ts-expect-error: only permits reading - d[2] = 3 -} - -// @ts-expect-error: push does not exist on readonly -d.push(3) - -const e: [number] = [0] - -// @ts-expect-error: [number] is not assignable to never -assertArrayIndex(e, 'e') - -const f: readonly [boolean] = [false] - -// @ts-expect-error: [boolean] is not assignable to never -assertArrayIndex(f, 'f') - -const tuple = [5, 7] as const - -// @ts-expect-error: readonly [5, 7] is not assignable to never +const matrix = [ + [3, 4], + [5, 6], + [7, 8], +] + +assertArrayIndex(matrix, 'rows') + +let sum = 0 + +for (let i = 0 as Index; i < matrix.length; i += 1) { + const columns: number[] = matrix[i] + + // @ts-expect-error: number | undefined in not assignable to number + const x: number[] = matrix[0] + + assertArrayIndex(columns, 'columns') + + for (let j = 0 as Index; j < columns.length; j += 1) { + sum += columns[j] + + // @ts-expect-error: number | undefined in not assignable to number + const y: number = columns[i] + + // @ts-expect-error: number | undefined in not assignable to number + const z: number = columns[0] + + // @ts-expect-error: number[] | undefined in not assignable to number[] + const u: number[] = matrix[j] + } +} + +const a: string[] = [] + +assertArrayIndex(a, 'a') + +for (let p = 0 as Index; p < a.length; p += 1) { + const value: string = a[p] + + // @ts-expect-error: string | undefined is not assignable to string + const z: string = a[2] +} + +a.push('qux') +// @ts-expect-error: number is not assignable to string +a.push(3) + +for (const value of a) { + const other: string = value +} + +const b: number[] = [] + +assertArrayIndex(b, 'b') + +for (let p = 0 as Index; p < b.length; p += 1) { + // @ts-expect-error: number | undefined is not assignable to string + const value: string = b[p] +} + +const c: string[] = [] + +assertArrayIndex(c, 'c') + +for (let p = 0; p < c.length; p += 1) { + // @ts-expect-error: string | undefined is not assignable to string + let value: string = c[p] + + // @ts-expect-error: string | undefined is not assignable to string + value = c[0 as Index] +} + +const d: readonly number[] = [] + +assertArrayIndex(d, 'd') + +for (let p = 0 as Index; p < d.length; p += 1) { + const value: number = d[p] + + // @ts-expect-error: only permits reading + d[2] = 3 +} + +// @ts-expect-error: push does not exist on readonly +d.push(3) + +const e: [number] = [0] + +// @ts-expect-error: [number] is not assignable to never +assertArrayIndex(e, 'e') + +const f: readonly [boolean] = [false] + +// @ts-expect-error: [boolean] is not assignable to never +assertArrayIndex(f, 'f') + +const tuple = [5, 7] as const + +// @ts-expect-error: readonly [5, 7] is not assignable to never assertArrayIndex(tuple, 'tuple') diff --git a/questions/949-medium-anyof/README.md b/questions/00949-medium-anyof/README.md similarity index 99% rename from questions/949-medium-anyof/README.md rename to questions/00949-medium-anyof/README.md index 9f37e3262..f7c1e910c 100644 --- a/questions/949-medium-anyof/README.md +++ b/questions/00949-medium-anyof/README.md @@ -1,12 +1,12 @@

AnyOf medium #array

by null @kynefuk

Take the Challenge

-Implement Python liked `any` function in the type system. A type takes the Array and returns `true` if any element of the Array is true. If the Array is empty, return `false`. - -For example: - -```ts -type Sample1 = AnyOf<[1, "", false, [], {}]>; // expected to be true. -type Sample2 = AnyOf<[0, "", false, [], {}]>; // expected to be false. +Implement Python liked `any` function in the type system. A type takes the Array and returns `true` if any element of the Array is true. If the Array is empty, return `false`. + +For example: + +```ts +type Sample1 = AnyOf<[1, "", false, [], {}]>; // expected to be true. +type Sample2 = AnyOf<[0, "", false, [], {}]>; // expected to be false. ``` diff --git a/questions/949-medium-anyof/info.yml b/questions/00949-medium-anyof/info.yml similarity index 100% rename from questions/949-medium-anyof/info.yml rename to questions/00949-medium-anyof/info.yml diff --git a/questions/949-medium-anyof/template.ts b/questions/00949-medium-anyof/template.ts similarity index 100% rename from questions/949-medium-anyof/template.ts rename to questions/00949-medium-anyof/template.ts diff --git a/questions/949-medium-anyof/test-cases.ts b/questions/00949-medium-anyof/test-cases.ts similarity index 98% rename from questions/949-medium-anyof/test-cases.ts rename to questions/00949-medium-anyof/test-cases.ts index 11e299c84..fb5efc7db 100644 --- a/questions/949-medium-anyof/test-cases.ts +++ b/questions/00949-medium-anyof/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, false>>, - Expect, false>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, false>>, + Expect, false>>, +] diff --git a/questions/956-hard-deeppick/README.md b/questions/00956-hard-deeppick/README.md similarity index 98% rename from questions/956-hard-deeppick/README.md rename to questions/00956-hard-deeppick/README.md index 4f64e4c4d..c48c47951 100644 --- a/questions/956-hard-deeppick/README.md +++ b/questions/00956-hard-deeppick/README.md @@ -1,30 +1,30 @@

DeepPick hard #deep

by hiroya iizuka @hiroyaiizuka

Take the Challenge

-Implement a type DeepPick, that extends Utility types `Pick`. -A type takes two arguments. - - -For example: - -``` - -type obj = { - name: 'hoge', - age: 20, - friend: { - name: 'fuga', - age: 30, - family: { - name: 'baz', - age: 1 - } - } -} - -type T1 = DeepPick // { name : 'hoge' } -type T2 = DeepPick // { name : 'hoge' } & { friend: { name: 'fuga' }} -type T3 = DeepPick // { name : 'hoge' } & { friend: { name: 'fuga' }} & { friend: { family: { name: 'baz' }}} - +Implement a type DeepPick, that extends Utility types `Pick`. +A type takes two arguments. + + +For example: + +``` + +type obj = { + name: 'hoge', + age: 20, + friend: { + name: 'fuga', + age: 30, + family: { + name: 'baz', + age: 1 + } + } +} + +type T1 = DeepPick // { name : 'hoge' } +type T2 = DeepPick // { name : 'hoge' } & { friend: { name: 'fuga' }} +type T3 = DeepPick // { name : 'hoge' } & { friend: { name: 'fuga' }} & { friend: { family: { name: 'baz' }}} + ``` diff --git a/questions/956-hard-deeppick/info.yml b/questions/00956-hard-deeppick/info.yml similarity index 100% rename from questions/956-hard-deeppick/info.yml rename to questions/00956-hard-deeppick/info.yml diff --git a/questions/956-hard-deeppick/template.ts b/questions/00956-hard-deeppick/template.ts similarity index 100% rename from questions/956-hard-deeppick/template.ts rename to questions/00956-hard-deeppick/template.ts diff --git a/questions/956-hard-deeppick/test-cases.ts b/questions/00956-hard-deeppick/test-cases.ts similarity index 95% rename from questions/956-hard-deeppick/test-cases.ts rename to questions/00956-hard-deeppick/test-cases.ts index dff07c555..9a46e3799 100644 --- a/questions/956-hard-deeppick/test-cases.ts +++ b/questions/00956-hard-deeppick/test-cases.ts @@ -1,29 +1,29 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Obj = { - a: number - b: string - c: boolean - obj: { - d: number - e: string - f: boolean - obj2: { - g: number - h: string - i: boolean - } - } - obj3: { - j: number - k: string - l: boolean - } -} - -type cases = [ - Expect, unknown >>, - Expect, { a: number }>>, - Expect, { a: number } & { obj: { e: string } }>>, - Expect, { a: number } & { obj: { e: string } } & { obj: { obj2: { i: boolean } } }>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Obj = { + a: number + b: string + c: boolean + obj: { + d: number + e: string + f: boolean + obj2: { + g: number + h: string + i: boolean + } + } + obj3: { + j: number + k: string + l: boolean + } +} + +type cases = [ + Expect, unknown >>, + Expect, { a: number }>>, + Expect, { a: number } & { obj: { e: string } }>>, + Expect, { a: number } & { obj: { e: string } } & { obj: { obj2: { i: boolean } } }>>, +] diff --git a/questions/1042-medium-isnever/README.md b/questions/01042-medium-isnever/README.md similarity index 70% rename from questions/1042-medium-isnever/README.md rename to questions/01042-medium-isnever/README.md index bb13edf20..b09ec7cfe 100644 --- a/questions/1042-medium-isnever/README.md +++ b/questions/01042-medium-isnever/README.md @@ -1,17 +1,17 @@ -

IsNever medium #union #utils

by hiroya iizuka @hiroyaiizuka

Take the Challenge

- -Implement a type IsNever, which takes input type `T`. -If the type of resolves to `never`, return `true`, otherwise `false`. - -For example: - -```ts -type A = IsNever // expected to be true -type B = IsNever // expected to be false -type C = IsNever // expected to be false -type D = IsNever<[]> // expected to be false -type E = IsNever // expected to be false -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

1097・IsUnion 223・IsAny 4484・IsTuple +

IsNever medium #union #utils

by hiroya iizuka @hiroyaiizuka

Take the Challenge

+ +Implement a type IsNever, which takes input type `T`. +If the type of resolves to `never`, return `true`, otherwise `false`. + +For example: + +```ts +type A = IsNever // expected to be true +type B = IsNever // expected to be false +type C = IsNever // expected to be false +type D = IsNever<[]> // expected to be false +type E = IsNever // expected to be false +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

1097・IsUnion 223・IsAny 4484・IsTuple diff --git a/questions/1042-medium-isnever/info.yml b/questions/01042-medium-isnever/info.yml similarity index 100% rename from questions/1042-medium-isnever/info.yml rename to questions/01042-medium-isnever/info.yml diff --git a/questions/1042-medium-isnever/template.ts b/questions/01042-medium-isnever/template.ts similarity index 100% rename from questions/1042-medium-isnever/template.ts rename to questions/01042-medium-isnever/template.ts diff --git a/questions/1042-medium-isnever/test-cases.ts b/questions/01042-medium-isnever/test-cases.ts similarity index 97% rename from questions/1042-medium-isnever/test-cases.ts rename to questions/01042-medium-isnever/test-cases.ts index 0870e7040..ecf03d6ba 100644 --- a/questions/1042-medium-isnever/test-cases.ts +++ b/questions/01042-medium-isnever/test-cases.ts @@ -1,11 +1,11 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, +] diff --git a/questions/1097-medium-isunion/README.md b/questions/01097-medium-isunion/README.md similarity index 66% rename from questions/1097-medium-isunion/README.md rename to questions/01097-medium-isunion/README.md index eb0e81838..8567d1771 100644 --- a/questions/1097-medium-isunion/README.md +++ b/questions/01097-medium-isunion/README.md @@ -1,14 +1,14 @@

IsUnion medium

by null @bencor

Take the Challenge

-Implement a type `IsUnion`, which takes an input type `T` and returns whether `T` resolves to a union type. - -For example: - - ```ts - type case1 = IsUnion // false - type case2 = IsUnion // true - type case3 = IsUnion<[string|number]> // false +Implement a type `IsUnion`, which takes an input type `T` and returns whether `T` resolves to a union type. + +For example: + + ```ts + type case1 = IsUnion // false + type case2 = IsUnion // true + type case3 = IsUnion<[string|number]> // false ``` -
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 223・IsAny 4484・IsTuple \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 223・IsAny 4484・IsTuple \ No newline at end of file diff --git a/questions/1097-medium-isunion/info.yml b/questions/01097-medium-isunion/info.yml similarity index 100% rename from questions/1097-medium-isunion/info.yml rename to questions/01097-medium-isunion/info.yml diff --git a/questions/1097-medium-isunion/template.ts b/questions/01097-medium-isunion/template.ts similarity index 100% rename from questions/1097-medium-isunion/template.ts rename to questions/01097-medium-isunion/template.ts diff --git a/questions/1097-medium-isunion/test-cases.ts b/questions/01097-medium-isunion/test-cases.ts similarity index 97% rename from questions/1097-medium-isunion/test-cases.ts rename to questions/01097-medium-isunion/test-cases.ts index 0a47f23b8..bed1f023c 100644 --- a/questions/1097-medium-isunion/test-cases.ts +++ b/questions/01097-medium-isunion/test-cases.ts @@ -1,16 +1,16 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, false >>, - Expect, true >>, - Expect, true >>, - Expect, true >>, - Expect, true >>, - Expect, false >>, - Expect, false >>, - // Cases where T resolves to a non-union type. - Expect, false >>, - Expect, false >>, - Expect, false >>, - Expect, false >>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, false >>, + Expect, true >>, + Expect, true >>, + Expect, true >>, + Expect, true >>, + Expect, false >>, + Expect, false >>, + // Cases where T resolves to a non-union type. + Expect, false >>, + Expect, false >>, + Expect, false >>, + Expect, false >>, ] diff --git a/questions/1130-medium-replacekeys/README.md b/questions/01130-medium-replacekeys/README.md similarity index 98% rename from questions/1130-medium-replacekeys/README.md rename to questions/01130-medium-replacekeys/README.md index 5a479eb95..a28561dbf 100644 --- a/questions/1130-medium-replacekeys/README.md +++ b/questions/01130-medium-replacekeys/README.md @@ -1,37 +1,37 @@ -

ReplaceKeys medium

by 贱贱 @lullabyjune

Take the Challenge

- -Implement a type ReplaceKeys, that replace keys in union types, if some type has not this key, just skip replacing, -A type takes three arguments. - - -For example: - -```ts -type NodeA = { - type: 'A' - name: string - flag: number -} - -type NodeB = { - type: 'B' - id: number - flag: number -} - -type NodeC = { - type: 'C' - name: string - flag: number -} - - -type Nodes = NodeA | NodeB | NodeC - -type ReplacedNodes = ReplaceKeys // {type: 'A', name: number, flag: string} | {type: 'B', id: number, flag: string} | {type: 'C', name: number, flag: string} // would replace name from string to number, replace flag from number to string. - -type ReplacedNotExistKeys = ReplaceKeys // {type: 'A', name: never, flag: number} | NodeB | {type: 'C', name: never, flag: number} // would replace name to never -``` - - -
Back Share your Solutions Check out Solutions +

ReplaceKeys medium

by 贱贱 @lullabyjune

Take the Challenge

+ +Implement a type ReplaceKeys, that replace keys in union types, if some type has not this key, just skip replacing, +A type takes three arguments. + + +For example: + +```ts +type NodeA = { + type: 'A' + name: string + flag: number +} + +type NodeB = { + type: 'B' + id: number + flag: number +} + +type NodeC = { + type: 'C' + name: string + flag: number +} + + +type Nodes = NodeA | NodeB | NodeC + +type ReplacedNodes = ReplaceKeys // {type: 'A', name: number, flag: string} | {type: 'B', id: number, flag: string} | {type: 'C', name: number, flag: string} // would replace name from string to number, replace flag from number to string. + +type ReplacedNotExistKeys = ReplaceKeys // {type: 'A', name: never, flag: number} | NodeB | {type: 'C', name: never, flag: number} // would replace name to never +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/1130-medium-replacekeys/info.yml b/questions/01130-medium-replacekeys/info.yml similarity index 100% rename from questions/1130-medium-replacekeys/info.yml rename to questions/01130-medium-replacekeys/info.yml diff --git a/questions/1130-medium-replacekeys/template.ts b/questions/01130-medium-replacekeys/template.ts similarity index 100% rename from questions/1130-medium-replacekeys/template.ts rename to questions/01130-medium-replacekeys/template.ts diff --git a/questions/1130-medium-replacekeys/test-cases.ts b/questions/01130-medium-replacekeys/test-cases.ts similarity index 94% rename from questions/1130-medium-replacekeys/test-cases.ts rename to questions/01130-medium-replacekeys/test-cases.ts index acec5291d..1395d7b85 100644 --- a/questions/1130-medium-replacekeys/test-cases.ts +++ b/questions/01130-medium-replacekeys/test-cases.ts @@ -1,58 +1,58 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type NodeA = { - type: 'A' - name: string - flag: number -} - -type NodeB = { - type: 'B' - id: number - flag: number -} - -type NodeC = { - type: 'C' - name: string - flag: number -} - -type ReplacedNodeA = { - type: 'A' - name: number - flag: string -} - -type ReplacedNodeB = { - type: 'B' - id: number - flag: string -} - -type ReplacedNodeC = { - type: 'C' - name: number - flag: string -} - -type NoNameNodeA = { - type: 'A' - flag: number - name: never -} - -type NoNameNodeC = { - type: 'C' - flag: number - name: never -} - -type Nodes = NodeA | NodeB | NodeC -type ReplacedNodes = ReplacedNodeA | ReplacedNodeB | ReplacedNodeC -type NodesNoName = NoNameNodeA | NoNameNodeC | NodeB - -type cases = [ - Expect, ReplacedNodes>>, - Expect, NodesNoName>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type NodeA = { + type: 'A' + name: string + flag: number +} + +type NodeB = { + type: 'B' + id: number + flag: number +} + +type NodeC = { + type: 'C' + name: string + flag: number +} + +type ReplacedNodeA = { + type: 'A' + name: number + flag: string +} + +type ReplacedNodeB = { + type: 'B' + id: number + flag: string +} + +type ReplacedNodeC = { + type: 'C' + name: number + flag: string +} + +type NoNameNodeA = { + type: 'A' + flag: number + name: never +} + +type NoNameNodeC = { + type: 'C' + flag: number + name: never +} + +type Nodes = NodeA | NodeB | NodeC +type ReplacedNodes = ReplacedNodeA | ReplacedNodeB | ReplacedNodeC +type NodesNoName = NoNameNodeA | NoNameNodeC | NodeB + +type cases = [ + Expect, ReplacedNodes>>, + Expect, NodesNoName>>, +] diff --git a/questions/1290-hard-pinia/README.md b/questions/01290-hard-pinia/README.md similarity index 97% rename from questions/1290-hard-pinia/README.md rename to questions/01290-hard-pinia/README.md index f73910038..90a5289ae 100644 --- a/questions/1290-hard-pinia/README.md +++ b/questions/01290-hard-pinia/README.md @@ -1,70 +1,70 @@

Pinia hard #this #vue

by Pig Fang @g-plane

Take the Challenge

-Create a type-level function whose types is similar to [Pinia](https://github.com/posva/pinia) library. You don't need to implement function actually, just adding types. - -### Overview - -This function receive only one parameter whose type is an object. The object contains 4 properties: - -- `id` - just a string (required) -- `state` - a function which will return an object as store's state (required) -- `getters` - an object with methods which is similar to Vue's computed values or Vuex's getters, and details are below (optional) -- `actions` - an object with methods which can do side effects and mutate state, and details are below (optional) - -### Getters - -When you define a store like this: - -```typescript -const store = defineStore({ - // ...other required fields - getters: { - getSomething() { - return 'xxx' - } - } -}) -``` - -And you should use it like this: - -```typescript -store.getSomething -``` - -instead of: - -```typescript -store.getSomething() // error -``` - -Additionally, getters can access state and/or other getters via `this`, but state is read-only. - -### Actions - -When you define a store like this: - -```typescript -const store = defineStore({ - // ...other required fields - actions: { - doSideEffect() { - this.xxx = 'xxx' - return 'ok' - } - } -}) -``` - -Using it is just to call it: - -```typescript -const returnValue = store.doSideEffect() -``` - -Actions can return any value or return nothing, and it can receive any number of parameters with different types. -Parameters types and return type can't be lost, which means type-checking must be available at call side. - +Create a type-level function whose types is similar to [Pinia](https://github.com/posva/pinia) library. You don't need to implement function actually, just adding types. + +### Overview + +This function receive only one parameter whose type is an object. The object contains 4 properties: + +- `id` - just a string (required) +- `state` - a function which will return an object as store's state (required) +- `getters` - an object with methods which is similar to Vue's computed values or Vuex's getters, and details are below (optional) +- `actions` - an object with methods which can do side effects and mutate state, and details are below (optional) + +### Getters + +When you define a store like this: + +```typescript +const store = defineStore({ + // ...other required fields + getters: { + getSomething() { + return 'xxx' + } + } +}) +``` + +And you should use it like this: + +```typescript +store.getSomething +``` + +instead of: + +```typescript +store.getSomething() // error +``` + +Additionally, getters can access state and/or other getters via `this`, but state is read-only. + +### Actions + +When you define a store like this: + +```typescript +const store = defineStore({ + // ...other required fields + actions: { + doSideEffect() { + this.xxx = 'xxx' + return 'ok' + } + } +}) +``` + +Using it is just to call it: + +```typescript +const returnValue = store.doSideEffect() +``` + +Actions can return any value or return nothing, and it can receive any number of parameters with different types. +Parameters types and return type can't be lost, which means type-checking must be available at call side. + State can be accessed and mutated via `this`. Getters can be accessed via `this` but they're read-only. diff --git a/questions/1290-hard-pinia/info.yml b/questions/01290-hard-pinia/info.yml similarity index 100% rename from questions/1290-hard-pinia/info.yml rename to questions/01290-hard-pinia/info.yml diff --git a/questions/1290-hard-pinia/template.ts b/questions/01290-hard-pinia/template.ts similarity index 100% rename from questions/1290-hard-pinia/template.ts rename to questions/01290-hard-pinia/template.ts diff --git a/questions/1290-hard-pinia/test-cases.ts b/questions/01290-hard-pinia/test-cases.ts similarity index 94% rename from questions/1290-hard-pinia/test-cases.ts rename to questions/01290-hard-pinia/test-cases.ts index 50d9c43db..c43616d01 100644 --- a/questions/1290-hard-pinia/test-cases.ts +++ b/questions/01290-hard-pinia/test-cases.ts @@ -1,66 +1,66 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -const store = defineStore({ - id: '', - state: () => ({ - num: 0, - str: '', - }), - getters: { - stringifiedNum() { - // @ts-expect-error - this.num += 1 - - return this.num.toString() - }, - parsedNum() { - return parseInt(this.stringifiedNum) - }, - }, - actions: { - init() { - this.reset() - this.increment() - }, - increment(step = 1) { - this.num += step - }, - reset() { - this.num = 0 - - // @ts-expect-error - this.parsedNum = 0 - - return true - }, - setNum(value: number) { - this.num = value - }, - }, -}) - -// @ts-expect-error -store.nopeStateProp -// @ts-expect-error -store.nopeGetter -// @ts-expect-error -store.stringifiedNum() -store.init() -// @ts-expect-error -store.init(0) -store.increment() -store.increment(2) -// @ts-expect-error -store.setNum() -// @ts-expect-error -store.setNum('3') -store.setNum(3) -const r = store.reset() - -type _tests = [ - Expect>, - Expect>, - Expect>, - Expect>, - Expect>, +import type { Equal, Expect } from '@type-challenges/utils' + +const store = defineStore({ + id: '', + state: () => ({ + num: 0, + str: '', + }), + getters: { + stringifiedNum() { + // @ts-expect-error + this.num += 1 + + return this.num.toString() + }, + parsedNum() { + return parseInt(this.stringifiedNum) + }, + }, + actions: { + init() { + this.reset() + this.increment() + }, + increment(step = 1) { + this.num += step + }, + reset() { + this.num = 0 + + // @ts-expect-error + this.parsedNum = 0 + + return true + }, + setNum(value: number) { + this.num = value + }, + }, +}) + +// @ts-expect-error +store.nopeStateProp +// @ts-expect-error +store.nopeGetter +// @ts-expect-error +store.stringifiedNum() +store.init() +// @ts-expect-error +store.init(0) +store.increment() +store.increment(2) +// @ts-expect-error +store.setNum() +// @ts-expect-error +store.setNum('3') +store.setNum(3) +const r = store.reset() + +type _tests = [ + Expect>, + Expect>, + Expect>, + Expect>, + Expect>, ] diff --git a/questions/1367-medium-remove-index-signature/README.md b/questions/01367-medium-remove-index-signature/README.md similarity index 98% rename from questions/1367-medium-remove-index-signature/README.md rename to questions/01367-medium-remove-index-signature/README.md index 9ecd47a97..f47e19790 100644 --- a/questions/1367-medium-remove-index-signature/README.md +++ b/questions/01367-medium-remove-index-signature/README.md @@ -1,18 +1,18 @@

Remove Index Signature medium

by hiroya iizuka @hiroyaiizuka

Take the Challenge

-Implement `RemoveIndexSignature` , exclude the index signature from object types. - -For example: - -``` - -type Foo = { - [key: string]: any; - foo(): void; -} - -type A = RemoveIndexSignature // expected { foo(): void } - +Implement `RemoveIndexSignature` , exclude the index signature from object types. + +For example: + +``` + +type Foo = { + [key: string]: any; + foo(): void; +} + +type A = RemoveIndexSignature // expected { foo(): void } + ``` diff --git a/questions/1367-medium-remove-index-signature/info.yml b/questions/01367-medium-remove-index-signature/info.yml similarity index 100% rename from questions/1367-medium-remove-index-signature/info.yml rename to questions/01367-medium-remove-index-signature/info.yml diff --git a/questions/1367-medium-remove-index-signature/template.ts b/questions/01367-medium-remove-index-signature/template.ts similarity index 100% rename from questions/1367-medium-remove-index-signature/template.ts rename to questions/01367-medium-remove-index-signature/template.ts diff --git a/questions/1367-medium-remove-index-signature/test-cases.ts b/questions/01367-medium-remove-index-signature/test-cases.ts similarity index 95% rename from questions/1367-medium-remove-index-signature/test-cases.ts rename to questions/01367-medium-remove-index-signature/test-cases.ts index c7e2cbd8d..6515e8ad1 100644 --- a/questions/1367-medium-remove-index-signature/test-cases.ts +++ b/questions/01367-medium-remove-index-signature/test-cases.ts @@ -1,22 +1,22 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Foo = { - [key: string]: any - foo(): void -} - -type Bar = { - [key: number]: any - bar(): void -} - -type Baz = { - bar(): void - baz: string -} - -type cases = [ - Expect, { foo(): void }>>, - Expect, { bar(): void }>>, - Expect, { bar(): void; baz: string }>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type Foo = { + [key: string]: any + foo(): void +} + +type Bar = { + [key: number]: any + bar(): void +} + +type Baz = { + bar(): void + baz: string +} + +type cases = [ + Expect, { foo(): void }>>, + Expect, { bar(): void }>>, + Expect, { bar(): void; baz: string }>>, +] diff --git a/questions/1383-hard-camelize/README.md b/questions/01383-hard-camelize/README.md similarity index 100% rename from questions/1383-hard-camelize/README.md rename to questions/01383-hard-camelize/README.md diff --git a/questions/1383-hard-camelize/info.yml b/questions/01383-hard-camelize/info.yml similarity index 100% rename from questions/1383-hard-camelize/info.yml rename to questions/01383-hard-camelize/info.yml diff --git a/questions/1383-hard-camelize/template.ts b/questions/01383-hard-camelize/template.ts similarity index 95% rename from questions/1383-hard-camelize/template.ts rename to questions/01383-hard-camelize/template.ts index 716ec193e..5a455d873 100644 --- a/questions/1383-hard-camelize/template.ts +++ b/questions/01383-hard-camelize/template.ts @@ -1 +1 @@ -type Camelize = any +type Camelize = any diff --git a/questions/1383-hard-camelize/test-cases.ts b/questions/01383-hard-camelize/test-cases.ts similarity index 95% rename from questions/1383-hard-camelize/test-cases.ts rename to questions/01383-hard-camelize/test-cases.ts index ea1394958..d5da8aca2 100644 --- a/questions/1383-hard-camelize/test-cases.ts +++ b/questions/01383-hard-camelize/test-cases.ts @@ -1,16 +1,16 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, - { - someProp: string - prop: { anotherProp: string } - array: [{ snakeCase: string }] - } - >>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, + { + someProp: string + prop: { anotherProp: string } + array: [{ snakeCase: string }] + } + >>, +] diff --git a/questions/1978-medium-percentage-parser/README.md b/questions/01978-medium-percentage-parser/README.md similarity index 98% rename from questions/1978-medium-percentage-parser/README.md rename to questions/01978-medium-percentage-parser/README.md index 2519a2bdf..66567cac7 100644 --- a/questions/1978-medium-percentage-parser/README.md +++ b/questions/01978-medium-percentage-parser/README.md @@ -1,24 +1,24 @@

Percentage Parser medium

by SSShuai1999 @SSShuai1999

Take the Challenge

-Implement PercentageParser. -According to the `/^(\+|\-)?(\d*)?(\%)?$/` regularity to match T and get three matches. - -The structure should be: [`plus or minus`, `number`, `unit`] -If it is not captured, the default is an empty string. - -For example: -```ts -type PString1 = '' -type PString2 = '+85%' -type PString3 = '-85%' -type PString4 = '85%' -type PString5 = '85' - -type R1 = PercentageParser // expected ['', '', ''] -type R2 = PercentageParser // expected ["+", "85", "%"] -type R3 = PercentageParser // expected ["-", "85", "%"] -type R4 = PercentageParser // expected ["", "85", "%"] -type R5 = PercentageParser // expected ["", "85", ""] +Implement PercentageParser. +According to the `/^(\+|\-)?(\d*)?(\%)?$/` regularity to match T and get three matches. + +The structure should be: [`plus or minus`, `number`, `unit`] +If it is not captured, the default is an empty string. + +For example: +```ts +type PString1 = '' +type PString2 = '+85%' +type PString3 = '-85%' +type PString4 = '85%' +type PString5 = '85' + +type R1 = PercentageParser // expected ['', '', ''] +type R2 = PercentageParser // expected ["+", "85", "%"] +type R3 = PercentageParser // expected ["-", "85", "%"] +type R4 = PercentageParser // expected ["", "85", "%"] +type R5 = PercentageParser // expected ["", "85", ""] ``` diff --git a/questions/1978-medium-percentage-parser/info.yml b/questions/01978-medium-percentage-parser/info.yml similarity index 100% rename from questions/1978-medium-percentage-parser/info.yml rename to questions/01978-medium-percentage-parser/info.yml diff --git a/questions/1978-medium-percentage-parser/template.ts b/questions/01978-medium-percentage-parser/template.ts similarity index 100% rename from questions/1978-medium-percentage-parser/template.ts rename to questions/01978-medium-percentage-parser/template.ts diff --git a/questions/1978-medium-percentage-parser/test-cases.ts b/questions/01978-medium-percentage-parser/test-cases.ts similarity index 97% rename from questions/1978-medium-percentage-parser/test-cases.ts rename to questions/01978-medium-percentage-parser/test-cases.ts index f8ca057cd..356164f6c 100644 --- a/questions/1978-medium-percentage-parser/test-cases.ts +++ b/questions/01978-medium-percentage-parser/test-cases.ts @@ -1,17 +1,17 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type Case1 = ['', '', ''] -type Case2 = ['+', '', ''] -type Case3 = ['+', '1', ''] -type Case4 = ['+', '100', '%'] -type Case5 = ['', '10', '%'] -type Case6 = ['-', '99', '%'] - -type cases = [ - Expect, Case1>>, - Expect, Case2>>, - Expect, Case3>>, - Expect, Case4>>, - Expect, Case5>>, - Expect, Case6>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type Case1 = ['', '', ''] +type Case2 = ['+', '', ''] +type Case3 = ['+', '1', ''] +type Case4 = ['+', '100', '%'] +type Case5 = ['', '10', '%'] +type Case6 = ['-', '99', '%'] + +type cases = [ + Expect, Case1>>, + Expect, Case2>>, + Expect, Case3>>, + Expect, Case4>>, + Expect, Case5>>, + Expect, Case6>>, ] diff --git a/questions/2059-hard-drop-string/README.md b/questions/02059-hard-drop-string/README.md similarity index 85% rename from questions/2059-hard-drop-string/README.md rename to questions/02059-hard-drop-string/README.md index 78566f8bb..7104513e7 100644 --- a/questions/2059-hard-drop-string/README.md +++ b/questions/02059-hard-drop-string/README.md @@ -1,12 +1,12 @@ -

Drop String hard #template-literal #infer

by CaptainOfPhB @CaptainOfPhB

Take the Challenge

- -Drop the specified chars from a string. - -For example: - -```ts -type Butterfly = DropString<'foobar!', 'fb'> // 'ooar!' -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

2070・Drop Char +

Drop String hard #template-literal #infer

by CaptainOfPhB @CaptainOfPhB

Take the Challenge

+ +Drop the specified chars from a string. + +For example: + +```ts +type Butterfly = DropString<'foobar!', 'fb'> // 'ooar!' +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

2070・Drop Char diff --git a/questions/2059-hard-drop-string/info.yml b/questions/02059-hard-drop-string/info.yml similarity index 100% rename from questions/2059-hard-drop-string/info.yml rename to questions/02059-hard-drop-string/info.yml diff --git a/questions/2059-hard-drop-string/template.ts b/questions/02059-hard-drop-string/template.ts similarity index 100% rename from questions/2059-hard-drop-string/template.ts rename to questions/02059-hard-drop-string/template.ts diff --git a/questions/2059-hard-drop-string/test-cases.ts b/questions/02059-hard-drop-string/test-cases.ts similarity index 98% rename from questions/2059-hard-drop-string/test-cases.ts rename to questions/02059-hard-drop-string/test-cases.ts index 09fb12ee3..e2464f7e6 100644 --- a/questions/2059-hard-drop-string/test-cases.ts +++ b/questions/02059-hard-drop-string/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'butter fly!'>>, - Expect, 'butterfly!'>>, - Expect, 'er fly!'>>, - Expect, ' e r f l y ! '>>, - Expect, 'butterfly!'>>, - Expect, 'butterfly!'>>, - Expect, ' e r f l y ! '>>, - Expect, ' e r f l y ! '>>, - Expect, ' u t t e r f l y ! '>>, - Expect, ' b u e r f l y ! '>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'butter fly!'>>, + Expect, 'butterfly!'>>, + Expect, 'er fly!'>>, + Expect, ' e r f l y ! '>>, + Expect, 'butterfly!'>>, + Expect, 'butterfly!'>>, + Expect, ' e r f l y ! '>>, + Expect, ' e r f l y ! '>>, + Expect, ' u t t e r f l y ! '>>, + Expect, ' b u e r f l y ! '>>, ] diff --git a/questions/2070-medium-drop-char/README.md b/questions/02070-medium-drop-char/README.md similarity index 85% rename from questions/2070-medium-drop-char/README.md rename to questions/02070-medium-drop-char/README.md index bc1c12a84..882aed112 100644 --- a/questions/2070-medium-drop-char/README.md +++ b/questions/02070-medium-drop-char/README.md @@ -1,12 +1,12 @@

Drop Char medium #template-literal #infer

by CaptainOfPhB @CaptainOfPhB

Take the Challenge

-Drop a specified char from a string. - -For example: - -```ts -type Butterfly = DropChar<' b u t t e r f l y ! ', ' '> // 'butterfly!' +Drop a specified char from a string. + +For example: + +```ts +type Butterfly = DropChar<' b u t t e r f l y ! ', ' '> // 'butterfly!' ``` -
Back Share your Solutions Check out Solutions

Related Challenges

2059・Drop String \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

2059・Drop String \ No newline at end of file diff --git a/questions/2070-medium-drop-char/info.yml b/questions/02070-medium-drop-char/info.yml similarity index 100% rename from questions/2070-medium-drop-char/info.yml rename to questions/02070-medium-drop-char/info.yml diff --git a/questions/2070-medium-drop-char/template.ts b/questions/02070-medium-drop-char/template.ts similarity index 100% rename from questions/2070-medium-drop-char/template.ts rename to questions/02070-medium-drop-char/template.ts diff --git a/questions/2070-medium-drop-char/test-cases.ts b/questions/02070-medium-drop-char/test-cases.ts similarity index 98% rename from questions/2070-medium-drop-char/test-cases.ts rename to questions/02070-medium-drop-char/test-cases.ts index 8f98338cc..c060a60c8 100644 --- a/questions/2070-medium-drop-char/test-cases.ts +++ b/questions/02070-medium-drop-char/test-cases.ts @@ -1,12 +1,12 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - // @ts-expect-error - Expect, 'butterfly!'>>, - Expect, 'butterfly!'>>, - Expect, 'butter fly'>>, - Expect, 'butterfly!'>>, - Expect, 'butterfly!'>>, - Expect, ' u t t e r f l y ! '>>, - Expect, ' b u e r f l y ! '>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + // @ts-expect-error + Expect, 'butterfly!'>>, + Expect, 'butterfly!'>>, + Expect, 'butter fly'>>, + Expect, 'butterfly!'>>, + Expect, 'butterfly!'>>, + Expect, ' u t t e r f l y ! '>>, + Expect, ' b u e r f l y ! '>>, ] diff --git a/questions/2257-medium-minusone/README.md b/questions/02257-medium-minusone/README.md similarity index 99% rename from questions/2257-medium-minusone/README.md rename to questions/02257-medium-minusone/README.md index ed8f964dd..0ef0c9e44 100644 --- a/questions/2257-medium-minusone/README.md +++ b/questions/02257-medium-minusone/README.md @@ -1,12 +1,12 @@

MinusOne medium #math

by Mustafo Faiz @fayzzzm

Take the Challenge

-Given a number (always positive) as a type. Your type should return the number decreased by one. - -For example: - -```ts -type Zero = MinusOne<1> // 0 -type FiftyFour = MinusOne<55> // 54 +Given a number (always positive) as a type. Your type should return the number decreased by one. + +For example: + +```ts +type Zero = MinusOne<1> // 0 +type FiftyFour = MinusOne<55> // 54 ``` diff --git a/questions/2257-medium-minusone/info.yml b/questions/02257-medium-minusone/info.yml similarity index 100% rename from questions/2257-medium-minusone/info.yml rename to questions/02257-medium-minusone/info.yml diff --git a/questions/2257-medium-minusone/template.ts b/questions/02257-medium-minusone/template.ts similarity index 100% rename from questions/2257-medium-minusone/template.ts rename to questions/02257-medium-minusone/template.ts diff --git a/questions/2257-medium-minusone/test-cases.ts b/questions/02257-medium-minusone/test-cases.ts similarity index 96% rename from questions/2257-medium-minusone/test-cases.ts rename to questions/02257-medium-minusone/test-cases.ts index fb21c5e75..6ebff206a 100644 --- a/questions/2257-medium-minusone/test-cases.ts +++ b/questions/02257-medium-minusone/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 0>>, - Expect, 54>>, - Expect, 2>>, - Expect, 99>>, - Expect, 1100>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 0>>, + Expect, 54>>, + Expect, 2>>, + Expect, 99>>, + Expect, 1100>>, ] diff --git a/questions/2595-medium-pickbytype/README.md b/questions/02595-medium-pickbytype/README.md similarity index 86% rename from questions/2595-medium-pickbytype/README.md rename to questions/02595-medium-pickbytype/README.md index 0f0a26e6e..d36da8a65 100644 --- a/questions/2595-medium-pickbytype/README.md +++ b/questions/02595-medium-pickbytype/README.md @@ -1,17 +1,17 @@

PickByType medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-From `T`, pick a set of properties whose type are assignable to `U`. - -For Example - -```typescript -type OnlyBoolean = PickByType<{ - name: string - count: number - isReadonly: boolean - isEnable: boolean -}, boolean> // { isReadonly: boolean; isEnable: boolean; } -``` +From `T`, pick a set of properties whose type are assignable to `U`. +For Example -
Back Share your Solutions Check out Solutions

Related Challenges

2852・OmitByType \ No newline at end of file +```typescript +type OnlyBoolean = PickByType<{ + name: string + count: number + isReadonly: boolean + isEnable: boolean +}, boolean> // { isReadonly: boolean; isEnable: boolean; } +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

2852・OmitByType \ No newline at end of file diff --git a/questions/2595-medium-pickbytype/info.yml b/questions/02595-medium-pickbytype/info.yml similarity index 100% rename from questions/2595-medium-pickbytype/info.yml rename to questions/02595-medium-pickbytype/info.yml diff --git a/questions/2595-medium-pickbytype/template.ts b/questions/02595-medium-pickbytype/template.ts similarity index 100% rename from questions/2595-medium-pickbytype/template.ts rename to questions/02595-medium-pickbytype/template.ts diff --git a/questions/2595-medium-pickbytype/test-cases.ts b/questions/02595-medium-pickbytype/test-cases.ts similarity index 96% rename from questions/2595-medium-pickbytype/test-cases.ts rename to questions/02595-medium-pickbytype/test-cases.ts index b109db747..bd8377610 100644 --- a/questions/2595-medium-pickbytype/test-cases.ts +++ b/questions/02595-medium-pickbytype/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -interface Model { - name: string - count: number - isReadonly: boolean - isEnable: boolean -} - -type cases = [ - Expect, { isReadonly: boolean; isEnable: boolean }>>, - Expect, { name: string }>>, - Expect, { count: number }>>, +import type { Equal, Expect } from '@type-challenges/utils' + +interface Model { + name: string + count: number + isReadonly: boolean + isEnable: boolean +} + +type cases = [ + Expect, { isReadonly: boolean; isEnable: boolean }>>, + Expect, { name: string }>>, + Expect, { count: number }>>, ] diff --git a/questions/2688-medium-startswith/README.md b/questions/02688-medium-startswith/README.md similarity index 87% rename from questions/2688-medium-startswith/README.md rename to questions/02688-medium-startswith/README.md index d96d6fdb1..74c9f27f5 100644 --- a/questions/2688-medium-startswith/README.md +++ b/questions/02688-medium-startswith/README.md @@ -1,14 +1,14 @@

StartsWith medium #template-literal

by jiangshan @jiangshanmeta

Take the Challenge

-Implement `StartsWith` which takes two exact string types and returns whether `T` starts with `U` - -For example - -```typescript -type a = StartsWith<'abc', 'ac'> // expected to be false -type b = StartsWith<'abc', 'ab'> // expected to be true -type c = StartsWith<'abc', 'abcd'> // expected to be false -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

2693・EndsWith \ No newline at end of file +Implement `StartsWith` which takes two exact string types and returns whether `T` starts with `U` + +For example + +```typescript +type a = StartsWith<'abc', 'ac'> // expected to be false +type b = StartsWith<'abc', 'ab'> // expected to be true +type c = StartsWith<'abc', 'abcd'> // expected to be false +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

2693・EndsWith \ No newline at end of file diff --git a/questions/2688-medium-startswith/info.yml b/questions/02688-medium-startswith/info.yml similarity index 100% rename from questions/2688-medium-startswith/info.yml rename to questions/02688-medium-startswith/info.yml diff --git a/questions/2688-medium-startswith/template.ts b/questions/02688-medium-startswith/template.ts similarity index 100% rename from questions/2688-medium-startswith/template.ts rename to questions/02688-medium-startswith/template.ts diff --git a/questions/2688-medium-startswith/test-cases.ts b/questions/02688-medium-startswith/test-cases.ts similarity index 97% rename from questions/2688-medium-startswith/test-cases.ts rename to questions/02688-medium-startswith/test-cases.ts index dfd94a3d4..05f02822c 100644 --- a/questions/2688-medium-startswith/test-cases.ts +++ b/questions/02688-medium-startswith/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, false>>, - Expect, true>>, - Expect, false>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, false>>, + Expect, true>>, + Expect, false>>, ] diff --git a/questions/2693-medium-endswith/README.md b/questions/02693-medium-endswith/README.md similarity index 85% rename from questions/2693-medium-endswith/README.md rename to questions/02693-medium-endswith/README.md index a2ba05320..c23816144 100644 --- a/questions/2693-medium-endswith/README.md +++ b/questions/02693-medium-endswith/README.md @@ -3,4 +3,4 @@ Implement `EndsWith` which takes two exact string types and returns whether `T` ends with `U` -
Back Share your Solutions Check out Solutions

Related Challenges

2688・StartsWith \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

2688・StartsWith \ No newline at end of file diff --git a/questions/2693-medium-endswith/info.yml b/questions/02693-medium-endswith/info.yml similarity index 100% rename from questions/2693-medium-endswith/info.yml rename to questions/02693-medium-endswith/info.yml diff --git a/questions/2693-medium-endswith/template.ts b/questions/02693-medium-endswith/template.ts similarity index 100% rename from questions/2693-medium-endswith/template.ts rename to questions/02693-medium-endswith/template.ts diff --git a/questions/2693-medium-endswith/test-cases.ts b/questions/02693-medium-endswith/test-cases.ts similarity index 97% rename from questions/2693-medium-endswith/test-cases.ts rename to questions/02693-medium-endswith/test-cases.ts index 085a17f93..27b377450 100644 --- a/questions/2693-medium-endswith/test-cases.ts +++ b/questions/02693-medium-endswith/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, true>>, - Expect, false>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, true>>, + Expect, false>>, ] diff --git a/questions/2757-medium-partialbykeys/README.md b/questions/02757-medium-partialbykeys/README.md similarity index 99% rename from questions/2757-medium-partialbykeys/README.md rename to questions/02757-medium-partialbykeys/README.md index 58b366c48..9d60972ca 100644 --- a/questions/2757-medium-partialbykeys/README.md +++ b/questions/02757-medium-partialbykeys/README.md @@ -1,19 +1,19 @@

PartialByKeys medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-Implement a generic `PartialByKeys` which takes two type argument `T` and `K`. - -`K` specify the set of properties of `T` that should set to be optional. When `K` is not provided, it should make all properties optional just like the normal `Partial`. - -For example - -```typescript -interface User { - name: string - age: number - address: string -} - -type UserPartialName = PartialByKeys // { name?:string; age:number; address:string } +Implement a generic `PartialByKeys` which takes two type argument `T` and `K`. + +`K` specify the set of properties of `T` that should set to be optional. When `K` is not provided, it should make all properties optional just like the normal `Partial`. + +For example + +```typescript +interface User { + name: string + age: number + address: string +} + +type UserPartialName = PartialByKeys // { name?:string; age:number; address:string } ``` diff --git a/questions/2757-medium-partialbykeys/info.yml b/questions/02757-medium-partialbykeys/info.yml similarity index 100% rename from questions/2757-medium-partialbykeys/info.yml rename to questions/02757-medium-partialbykeys/info.yml diff --git a/questions/2757-medium-partialbykeys/template.ts b/questions/02757-medium-partialbykeys/template.ts similarity index 100% rename from questions/2757-medium-partialbykeys/template.ts rename to questions/02757-medium-partialbykeys/template.ts diff --git a/questions/2757-medium-partialbykeys/test-cases.ts b/questions/02757-medium-partialbykeys/test-cases.ts similarity index 96% rename from questions/2757-medium-partialbykeys/test-cases.ts rename to questions/02757-medium-partialbykeys/test-cases.ts index 2be89002f..fe7fd25f6 100644 --- a/questions/2757-medium-partialbykeys/test-cases.ts +++ b/questions/02757-medium-partialbykeys/test-cases.ts @@ -1,27 +1,27 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface User { - name: string - age: number - address: string -} - -interface UserPartialName { - name?: string - age: number - address: string -} - -interface UserPartialNameAndAge { - name?: string - age?: number - address: string -} - -type cases = [ - Expect, UserPartialName>>, - Expect, UserPartialName>>, - Expect, UserPartialNameAndAge>>, - Expect, Partial>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface User { + name: string + age: number + address: string +} + +interface UserPartialName { + name?: string + age: number + address: string +} + +interface UserPartialNameAndAge { + name?: string + age?: number + address: string +} + +type cases = [ + Expect, UserPartialName>>, + Expect, UserPartialName>>, + Expect, UserPartialNameAndAge>>, + Expect, Partial>>, ] diff --git a/questions/2759-medium-requiredbykeys/README.md b/questions/02759-medium-requiredbykeys/README.md similarity index 99% rename from questions/2759-medium-requiredbykeys/README.md rename to questions/02759-medium-requiredbykeys/README.md index 2e955164b..b63ea5881 100644 --- a/questions/2759-medium-requiredbykeys/README.md +++ b/questions/02759-medium-requiredbykeys/README.md @@ -1,20 +1,20 @@

RequiredByKeys medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-Implement a generic `RequiredByKeys` which takes two type argument `T` and `K`. - -`K` specify the set of properties of `T` that should set to be required. When `K` is not provided, it should make all properties required just like the normal `Required`. - -For example - -```typescript -interface User { - name?: string - age?: number - address?: string -} - -type UserPartialName = RequiredByKeys // { name: string; age?: number; address?: string } - +Implement a generic `RequiredByKeys` which takes two type argument `T` and `K`. + +`K` specify the set of properties of `T` that should set to be required. When `K` is not provided, it should make all properties required just like the normal `Required`. + +For example + +```typescript +interface User { + name?: string + age?: number + address?: string +} + +type UserPartialName = RequiredByKeys // { name: string; age?: number; address?: string } + ``` diff --git a/questions/2759-medium-requiredbykeys/info.yml b/questions/02759-medium-requiredbykeys/info.yml similarity index 100% rename from questions/2759-medium-requiredbykeys/info.yml rename to questions/02759-medium-requiredbykeys/info.yml diff --git a/questions/2759-medium-requiredbykeys/template.ts b/questions/02759-medium-requiredbykeys/template.ts similarity index 100% rename from questions/2759-medium-requiredbykeys/template.ts rename to questions/02759-medium-requiredbykeys/template.ts diff --git a/questions/2759-medium-requiredbykeys/test-cases.ts b/questions/02759-medium-requiredbykeys/test-cases.ts similarity index 96% rename from questions/2759-medium-requiredbykeys/test-cases.ts rename to questions/02759-medium-requiredbykeys/test-cases.ts index 22ea3d55d..2a66dc80a 100644 --- a/questions/2759-medium-requiredbykeys/test-cases.ts +++ b/questions/02759-medium-requiredbykeys/test-cases.ts @@ -1,27 +1,27 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface User { - name?: string - age?: number - address?: string -} - -interface UserRequiredName { - name: string - age?: number - address?: string -} - -interface UserRequiredNameAndAge { - name: string - age: number - address?: string -} - -type cases = [ - Expect, UserRequiredName>>, - Expect, UserRequiredName>>, - Expect, UserRequiredNameAndAge>>, - Expect, Required>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface User { + name?: string + age?: number + address?: string +} + +interface UserRequiredName { + name: string + age?: number + address?: string +} + +interface UserRequiredNameAndAge { + name: string + age: number + address?: string +} + +type cases = [ + Expect, UserRequiredName>>, + Expect, UserRequiredName>>, + Expect, UserRequiredNameAndAge>>, + Expect, Required>>, ] diff --git a/questions/2793-medium-mutable/README.md b/questions/02793-medium-mutable/README.md similarity index 98% rename from questions/2793-medium-mutable/README.md rename to questions/02793-medium-mutable/README.md index cb95f9358..d4238ad0a 100644 --- a/questions/2793-medium-mutable/README.md +++ b/questions/02793-medium-mutable/README.md @@ -1,19 +1,19 @@ -

Mutable medium #readonly #object-keys

by jiangshan @jiangshanmeta

Take the Challenge

- -Implement the generic ```Mutable``` which makes all properties in ```T``` mutable (not readonly). - -For example - -```typescript -interface Todo { - readonly title: string - readonly description: string - readonly completed: boolean -} - -type MutableTodo = Mutable // { title: string; description: string; completed: boolean; } - -``` - - -
Back Share your Solutions Check out Solutions +

Mutable medium #readonly #object-keys

by jiangshan @jiangshanmeta

Take the Challenge

+ +Implement the generic ```Mutable``` which makes all properties in ```T``` mutable (not readonly). + +For example + +```typescript +interface Todo { + readonly title: string + readonly description: string + readonly completed: boolean +} + +type MutableTodo = Mutable // { title: string; description: string; completed: boolean; } + +``` + + +
Back Share your Solutions Check out Solutions diff --git a/questions/2793-medium-mutable/info.yml b/questions/02793-medium-mutable/info.yml similarity index 100% rename from questions/2793-medium-mutable/info.yml rename to questions/02793-medium-mutable/info.yml diff --git a/questions/2793-medium-mutable/template.ts b/questions/02793-medium-mutable/template.ts similarity index 100% rename from questions/2793-medium-mutable/template.ts rename to questions/02793-medium-mutable/template.ts diff --git a/questions/2793-medium-mutable/test-cases.ts b/questions/02793-medium-mutable/test-cases.ts similarity index 95% rename from questions/2793-medium-mutable/test-cases.ts rename to questions/02793-medium-mutable/test-cases.ts index 9252b4235..bd4b328d9 100644 --- a/questions/2793-medium-mutable/test-cases.ts +++ b/questions/02793-medium-mutable/test-cases.ts @@ -1,15 +1,15 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface Todo1 { - title: string - description: string - completed: boolean - meta: { - author: string - } -} - -type cases = [ - Expect>, Todo1>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface Todo1 { + title: string + description: string + completed: boolean + meta: { + author: string + } +} + +type cases = [ + Expect>, Todo1>>, ] diff --git a/questions/2822-hard-split/README.md b/questions/02822-hard-split/README.md similarity index 99% rename from questions/2822-hard-split/README.md rename to questions/02822-hard-split/README.md index b8a378527..b317786c0 100644 --- a/questions/2822-hard-split/README.md +++ b/questions/02822-hard-split/README.md @@ -1,11 +1,11 @@

Split hard #string #split #array #tuple

by Andrea Simone Costa @jfet97

Take the Challenge

-The well known `split()` method splits a string into an array of substrings by looking for a separator, and returns the new array. The goal of this challenge is to split a string, by using a separator, but in the type system! - -For example: - -```ts -type result = Split<'Hi! How are you?', ' '> // should be ['Hi!', 'How', 'are', 'you?'] +The well known `split()` method splits a string into an array of substrings by looking for a separator, and returns the new array. The goal of this challenge is to split a string, by using a separator, but in the type system! + +For example: + +```ts +type result = Split<'Hi! How are you?', ' '> // should be ['Hi!', 'How', 'are', 'you?'] ``` diff --git a/questions/2822-hard-split/info.yml b/questions/02822-hard-split/info.yml similarity index 100% rename from questions/2822-hard-split/info.yml rename to questions/02822-hard-split/info.yml diff --git a/questions/2822-hard-split/template.ts b/questions/02822-hard-split/template.ts similarity index 100% rename from questions/2822-hard-split/template.ts rename to questions/02822-hard-split/template.ts diff --git a/questions/2822-hard-split/test-cases.ts b/questions/02822-hard-split/test-cases.ts similarity index 98% rename from questions/2822-hard-split/test-cases.ts rename to questions/02822-hard-split/test-cases.ts index 2d78ce8a3..23440d30e 100644 --- a/questions/2822-hard-split/test-cases.ts +++ b/questions/02822-hard-split/test-cases.ts @@ -1,11 +1,11 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, ['Hi! How are you?']>>, - Expect, ['Hi!', 'How', 'are', 'you?']>>, - Expect, ['H', 'i', '!', ' ', 'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u', '?']>>, - Expect, []>>, - Expect, ['']>>, - Expect, string[]>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, ['Hi! How are you?']>>, + Expect, ['Hi!', 'How', 'are', 'you?']>>, + Expect, ['H', 'i', '!', ' ', 'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u', '?']>>, + Expect, []>>, + Expect, ['']>>, + Expect, string[]>>, ] diff --git a/questions/2828-hard-classpublickeys/README.md b/questions/02828-hard-classpublickeys/README.md similarity index 98% rename from questions/2828-hard-classpublickeys/README.md rename to questions/02828-hard-classpublickeys/README.md index 9c38902ec..cee661ff8 100644 --- a/questions/2828-hard-classpublickeys/README.md +++ b/questions/02828-hard-classpublickeys/README.md @@ -1,21 +1,21 @@

ClassPublicKeys hard #utils

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the generic `ClassPublicKeys` which returns all public keys of a class. - -For example: - -```ts -class A { - public str: string - protected num: number - private bool: boolean - getNum() { - return Math.random() - } -} - -type publicKyes = ClassPublicKeys // 'str' | 'getNum' -``` +Implement the generic `ClassPublicKeys` which returns all public keys of a class. + +For example: + +```ts +class A { + public str: string + protected num: number + private bool: boolean + getNum() { + return Math.random() + } +} + +type publicKyes = ClassPublicKeys // 'str' | 'getNum' +```
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/2828-hard-classpublickeys/info.yml b/questions/02828-hard-classpublickeys/info.yml similarity index 100% rename from questions/2828-hard-classpublickeys/info.yml rename to questions/02828-hard-classpublickeys/info.yml diff --git a/questions/2828-hard-classpublickeys/template.ts b/questions/02828-hard-classpublickeys/template.ts similarity index 100% rename from questions/2828-hard-classpublickeys/template.ts rename to questions/02828-hard-classpublickeys/template.ts diff --git a/questions/2828-hard-classpublickeys/test-cases.ts b/questions/02828-hard-classpublickeys/test-cases.ts similarity index 95% rename from questions/2828-hard-classpublickeys/test-cases.ts rename to questions/02828-hard-classpublickeys/test-cases.ts index 37977eb46..5120841b5 100644 --- a/questions/2828-hard-classpublickeys/test-cases.ts +++ b/questions/02828-hard-classpublickeys/test-cases.ts @@ -1,21 +1,21 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -class A { - public str: string - protected num: number - private bool: boolean - constructor() { - this.str = 'naive' - this.num = 19260917 - this.bool = true +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +class A { + public str: string + protected num: number + private bool: boolean + constructor() { + this.str = 'naive' + this.num = 19260917 + this.bool = true } - - getNum() { - return Math.random() - } -} - -type cases = [ - Expect, 'str' | 'getNum'>>, -] + + getNum() { + return Math.random() + } +} + +type cases = [ + Expect, 'str' | 'getNum'>>, +] diff --git a/questions/2852-medium-omitbytype/README.md b/questions/02852-medium-omitbytype/README.md similarity index 85% rename from questions/2852-medium-omitbytype/README.md rename to questions/02852-medium-omitbytype/README.md index 4c19394d6..ba03456d1 100644 --- a/questions/2852-medium-omitbytype/README.md +++ b/questions/02852-medium-omitbytype/README.md @@ -1,17 +1,17 @@ -

OmitByType medium #object

by jiangshan @jiangshanmeta

Take the Challenge

- -From ```T```, pick a set of properties whose type are not assignable to ```U```. - -For Example - -```typescript -type OmitBoolean = OmitByType<{ - name: string - count: number - isReadonly: boolean - isEnable: boolean -}, boolean> // { name: string; count: number } -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

2595・PickByType +

OmitByType medium #object

by jiangshan @jiangshanmeta

Take the Challenge

+ +From ```T```, pick a set of properties whose type are not assignable to ```U```. + +For Example + +```typescript +type OmitBoolean = OmitByType<{ + name: string + count: number + isReadonly: boolean + isEnable: boolean +}, boolean> // { name: string; count: number } +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

2595・PickByType diff --git a/questions/2852-medium-omitbytype/info.yml b/questions/02852-medium-omitbytype/info.yml similarity index 100% rename from questions/2852-medium-omitbytype/info.yml rename to questions/02852-medium-omitbytype/info.yml diff --git a/questions/2852-medium-omitbytype/template.ts b/questions/02852-medium-omitbytype/template.ts similarity index 100% rename from questions/2852-medium-omitbytype/template.ts rename to questions/02852-medium-omitbytype/template.ts diff --git a/questions/2852-medium-omitbytype/test-cases.ts b/questions/02852-medium-omitbytype/test-cases.ts similarity index 97% rename from questions/2852-medium-omitbytype/test-cases.ts rename to questions/02852-medium-omitbytype/test-cases.ts index 50d56c397..45c3fbe8d 100644 --- a/questions/2852-medium-omitbytype/test-cases.ts +++ b/questions/02852-medium-omitbytype/test-cases.ts @@ -1,15 +1,15 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface Model { - name: string - count: number - isReadonly: boolean - isEnable: boolean -} - -type cases = [ - Expect, { name: string; count: number }>>, - Expect, { count: number; isReadonly: boolean; isEnable: boolean }>>, - Expect, { name: string; isReadonly: boolean; isEnable: boolean }>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface Model { + name: string + count: number + isReadonly: boolean + isEnable: boolean +} + +type cases = [ + Expect, { name: string; count: number }>>, + Expect, { count: number; isReadonly: boolean; isEnable: boolean }>>, + Expect, { name: string; isReadonly: boolean; isEnable: boolean }>>, ] diff --git a/questions/2857-hard-isrequiredkey/README.md b/questions/02857-hard-isrequiredkey/README.md similarity index 99% rename from questions/2857-hard-isrequiredkey/README.md rename to questions/02857-hard-isrequiredkey/README.md index ea5afe1c7..1799663d6 100644 --- a/questions/2857-hard-isrequiredkey/README.md +++ b/questions/02857-hard-isrequiredkey/README.md @@ -1,14 +1,14 @@

IsRequiredKey hard #utils

by jiangshan @jiangshanmeta

Take the Challenge

-Implement a generic ```IsRequiredKey``` that return whether ```K``` are required keys of ```T``` . - -For example - -```typescript -type A = IsRequiredKey<{ a: number, b?: string },'a'> // true -type B = IsRequiredKey<{ a: number, b?: string },'b'> // false -type C = IsRequiredKey<{ a: number, b?: string },'b' | 'a'> // false -``` +Implement a generic ```IsRequiredKey``` that return whether ```K``` are required keys of ```T``` . + +For example + +```typescript +type A = IsRequiredKey<{ a: number, b?: string },'a'> // true +type B = IsRequiredKey<{ a: number, b?: string },'b'> // false +type C = IsRequiredKey<{ a: number, b?: string },'b' | 'a'> // false +```
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/2857-hard-isrequiredkey/info.yml b/questions/02857-hard-isrequiredkey/info.yml similarity index 100% rename from questions/2857-hard-isrequiredkey/info.yml rename to questions/02857-hard-isrequiredkey/info.yml diff --git a/questions/2857-hard-isrequiredkey/template.ts b/questions/02857-hard-isrequiredkey/template.ts similarity index 100% rename from questions/2857-hard-isrequiredkey/template.ts rename to questions/02857-hard-isrequiredkey/template.ts diff --git a/questions/2857-hard-isrequiredkey/test-cases.ts b/questions/02857-hard-isrequiredkey/test-cases.ts similarity index 98% rename from questions/2857-hard-isrequiredkey/test-cases.ts rename to questions/02857-hard-isrequiredkey/test-cases.ts index 5e3873e94..e3b517b55 100644 --- a/questions/2857-hard-isrequiredkey/test-cases.ts +++ b/questions/02857-hard-isrequiredkey/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, false>>, - Expect, false>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, false>>, + Expect, false>>, ] diff --git a/questions/2946-medium-objectentries/README.md b/questions/02946-medium-objectentries/README.md similarity index 99% rename from questions/2946-medium-objectentries/README.md rename to questions/02946-medium-objectentries/README.md index 0b302a9eb..8f233927f 100644 --- a/questions/2946-medium-objectentries/README.md +++ b/questions/02946-medium-objectentries/README.md @@ -1,16 +1,16 @@

ObjectEntries medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Object.entries``` - -For example - -```typescript -interface Model { - name: string; - age: number; - locations: string[] | null; -} -type modelEntries = ObjectEntries // ['name', string] | ['age', number] | ['locations', string[] | null]; +Implement the type version of ```Object.entries``` + +For example + +```typescript +interface Model { + name: string; + age: number; + locations: string[] | null; +} +type modelEntries = ObjectEntries // ['name', string] | ['age', number] | ['locations', string[] | null]; ``` diff --git a/questions/2946-medium-objectentries/info.yml b/questions/02946-medium-objectentries/info.yml similarity index 100% rename from questions/2946-medium-objectentries/info.yml rename to questions/02946-medium-objectentries/info.yml diff --git a/questions/2946-medium-objectentries/template.ts b/questions/02946-medium-objectentries/template.ts similarity index 100% rename from questions/2946-medium-objectentries/template.ts rename to questions/02946-medium-objectentries/template.ts diff --git a/questions/2946-medium-objectentries/test-cases.ts b/questions/02946-medium-objectentries/test-cases.ts similarity index 97% rename from questions/2946-medium-objectentries/test-cases.ts rename to questions/02946-medium-objectentries/test-cases.ts index 8bcf48717..f3871d5ab 100644 --- a/questions/2946-medium-objectentries/test-cases.ts +++ b/questions/02946-medium-objectentries/test-cases.ts @@ -1,17 +1,17 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface Model { - name: string - age: number - locations: string[] | null -} - -type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null] - -type cases = [ - Expect, ModelEntries>>, - Expect>, ModelEntries>>, - Expect, ['key', undefined]>>, - Expect, ['key', undefined]>>, -] +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface Model { + name: string + age: number + locations: string[] | null +} + +type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null] + +type cases = [ + Expect, ModelEntries>>, + Expect>, ModelEntries>>, + Expect, ['key', undefined]>>, + Expect, ['key', undefined]>>, +] diff --git a/questions/2949-hard-objectfromentries/README.md b/questions/02949-hard-objectfromentries/README.md similarity index 84% rename from questions/2949-hard-objectfromentries/README.md rename to questions/02949-hard-objectfromentries/README.md index b4f00cf65..43ee14d5a 100644 --- a/questions/2949-hard-objectfromentries/README.md +++ b/questions/02949-hard-objectfromentries/README.md @@ -1,20 +1,20 @@

ObjectFromEntries hard #object

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Object.fromEntries``` - -For example: - -```typescript -interface Model { - name: string; - age: number; - locations: string[] | null; -} - -type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null]; - -type result = ObjectFromEntries // expected to be Model +Implement the type version of ```Object.fromEntries``` + +For example: + +```typescript +interface Model { + name: string; + age: number; + locations: string[] | null; +} + +type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null]; + +type result = ObjectFromEntries // expected to be Model ``` -
Back Share your Solutions Check out Solutions

Related Challenges

55・Union to Intersection \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

55・Union to Intersection \ No newline at end of file diff --git a/questions/2949-hard-objectfromentries/info.yml b/questions/02949-hard-objectfromentries/info.yml similarity index 100% rename from questions/2949-hard-objectfromentries/info.yml rename to questions/02949-hard-objectfromentries/info.yml diff --git a/questions/2949-hard-objectfromentries/template.ts b/questions/02949-hard-objectfromentries/template.ts similarity index 100% rename from questions/2949-hard-objectfromentries/template.ts rename to questions/02949-hard-objectfromentries/template.ts diff --git a/questions/2949-hard-objectfromentries/test-cases.ts b/questions/02949-hard-objectfromentries/test-cases.ts similarity index 96% rename from questions/2949-hard-objectfromentries/test-cases.ts rename to questions/02949-hard-objectfromentries/test-cases.ts index 66da36563..cf02d557c 100644 --- a/questions/2949-hard-objectfromentries/test-cases.ts +++ b/questions/02949-hard-objectfromentries/test-cases.ts @@ -1,14 +1,14 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -interface Model { - name: string - age: number - locations: string[] | null -} - -type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null] - -type cases = [ - Expect, Model>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +interface Model { + name: string + age: number + locations: string[] | null +} + +type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null] + +type cases = [ + Expect, Model>>, ] diff --git a/questions/3057-easy-push/README.ko.md b/questions/03057-easy-push/README.ko.md similarity index 77% rename from questions/3057-easy-push/README.ko.md rename to questions/03057-easy-push/README.ko.md index ea3a3b2e6..620698681 100644 --- a/questions/3057-easy-push/README.ko.md +++ b/questions/03057-easy-push/README.ko.md @@ -1,12 +1,12 @@ -

Push 쉬움 #array

by jiangshan @jiangshanmeta

도전하기    English 简体中文

- -`Array.push`의 제네릭 버전을 구현하세요. - -예시: - -```typescript -type Result = Push<[1, 2], '3'> // [1, 2, '3'] -``` - - -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

533・Concat 3060・Unshift \ No newline at end of file +

Push 쉬움 #array

by jiangshan @jiangshanmeta

도전하기    English 简体中文

+ +`Array.push`의 제네릭 버전을 구현하세요. + +예시: + +```typescript +type Result = Push<[1, 2], '3'> // [1, 2, '3'] +``` + + +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

533・Concat 3060・Unshift \ No newline at end of file diff --git a/questions/3057-easy-push/README.md b/questions/03057-easy-push/README.md similarity index 78% rename from questions/3057-easy-push/README.md rename to questions/03057-easy-push/README.md index 755251589..428f9b471 100644 --- a/questions/3057-easy-push/README.md +++ b/questions/03057-easy-push/README.md @@ -1,12 +1,12 @@

Push easy #array

by jiangshan @jiangshanmeta

Take the Challenge    简体中文 한국어

-Implement the generic version of ```Array.push``` - -For example - -```typescript -type Result = Push<[1, 2], '3'> // [1, 2, '3'] +Implement the generic version of ```Array.push``` + +For example + +```typescript +type Result = Push<[1, 2], '3'> // [1, 2, '3'] ``` -
Back Share your Solutions Check out Solutions

Related Challenges

533・Concat 3060・Unshift \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

533・Concat 3060・Unshift \ No newline at end of file diff --git a/questions/3057-easy-push/README.zh-CN.md b/questions/03057-easy-push/README.zh-CN.md similarity index 77% rename from questions/3057-easy-push/README.zh-CN.md rename to questions/03057-easy-push/README.zh-CN.md index 8cd8b0a2b..0ebe40cf9 100644 --- a/questions/3057-easy-push/README.zh-CN.md +++ b/questions/03057-easy-push/README.zh-CN.md @@ -1,12 +1,12 @@ -

Push 简单 #array

by jiangshan @jiangshanmeta

接受挑战    English 한국어

- -在类型系统里实现通用的 ```Array.push``` 。 - -举例如下, - -```typescript -type Result = Push<[1, 2], '3'> // [1, 2, '3'] -``` - - -
返回首页 分享你的解答 查看解答

相关挑战

533・Concat 3060・Unshift \ No newline at end of file +

Push 简单 #array

by jiangshan @jiangshanmeta

接受挑战    English 한국어

+ +在类型系统里实现通用的 ```Array.push``` 。 + +举例如下, + +```typescript +type Result = Push<[1, 2], '3'> // [1, 2, '3'] +``` + + +
返回首页 分享你的解答 查看解答

相关挑战

533・Concat 3060・Unshift \ No newline at end of file diff --git a/questions/3057-easy-push/info.yml b/questions/03057-easy-push/info.yml similarity index 100% rename from questions/3057-easy-push/info.yml rename to questions/03057-easy-push/info.yml diff --git a/questions/3057-easy-push/template.ts b/questions/03057-easy-push/template.ts similarity index 100% rename from questions/3057-easy-push/template.ts rename to questions/03057-easy-push/template.ts diff --git a/questions/3057-easy-push/test-cases.ts b/questions/03057-easy-push/test-cases.ts similarity index 98% rename from questions/3057-easy-push/test-cases.ts rename to questions/03057-easy-push/test-cases.ts index c636d660c..896cbec23 100644 --- a/questions/3057-easy-push/test-cases.ts +++ b/questions/03057-easy-push/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, [1]>>, - Expect, [1, 2, '3']>>, - Expect, ['1', 2, '3', boolean]>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, [1]>>, + Expect, [1, 2, '3']>>, + Expect, ['1', 2, '3', boolean]>>, ] diff --git a/questions/3060-easy-unshift/README.ko.md b/questions/03060-easy-unshift/README.ko.md similarity index 77% rename from questions/3060-easy-unshift/README.ko.md rename to questions/03060-easy-unshift/README.ko.md index 3d53f2603..4dfd4f5f2 100644 --- a/questions/3060-easy-unshift/README.ko.md +++ b/questions/03060-easy-unshift/README.ko.md @@ -1,12 +1,12 @@ -

Unshift 쉬움 #array

by jiangshan @jiangshanmeta

도전하기    English 简体中文

- -`Array.unshift`의 타입 버전을 구현하세요. - -예시: - -```typescript -type Result = Unshift<[1, 2], 0> // [0, 1, 2,] -``` - - -
돌아가기 정답 공유하기 정답 보기

관련된 문제들

533・Concat 3057・Push \ No newline at end of file +

Unshift 쉬움 #array

by jiangshan @jiangshanmeta

도전하기    English 简体中文

+ +`Array.unshift`의 타입 버전을 구현하세요. + +예시: + +```typescript +type Result = Unshift<[1, 2], 0> // [0, 1, 2,] +``` + + +
돌아가기 정답 공유하기 정답 보기

관련된 문제들

533・Concat 3057・Push \ No newline at end of file diff --git a/questions/3060-easy-unshift/README.md b/questions/03060-easy-unshift/README.md similarity index 78% rename from questions/3060-easy-unshift/README.md rename to questions/03060-easy-unshift/README.md index 817cf9a0c..eebb792d5 100644 --- a/questions/3060-easy-unshift/README.md +++ b/questions/03060-easy-unshift/README.md @@ -1,12 +1,12 @@

Unshift easy #array

by jiangshan @jiangshanmeta

Take the Challenge    简体中文 한국어

-Implement the type version of ```Array.unshift``` - -For example - -```typescript -type Result = Unshift<[1, 2], 0> // [0, 1, 2,] +Implement the type version of ```Array.unshift``` + +For example + +```typescript +type Result = Unshift<[1, 2], 0> // [0, 1, 2,] ``` -
Back Share your Solutions Check out Solutions

Related Challenges

533・Concat 3057・Push \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

533・Concat 3057・Push \ No newline at end of file diff --git a/questions/3060-easy-unshift/README.zh-CN.md b/questions/03060-easy-unshift/README.zh-CN.md similarity index 77% rename from questions/3060-easy-unshift/README.zh-CN.md rename to questions/03060-easy-unshift/README.zh-CN.md index 5b96a937e..d1f2f4480 100644 --- a/questions/3060-easy-unshift/README.zh-CN.md +++ b/questions/03060-easy-unshift/README.zh-CN.md @@ -1,12 +1,12 @@ -

Unshift 简单 #array

by jiangshan @jiangshanmeta

接受挑战    English 한국어

- -实现类型版本的 ```Array.unshift```。 - -举例, - -```typescript -type Result = Unshift<[1, 2], 0> // [0, 1, 2,] -``` - - -
返回首页 分享你的解答 查看解答

相关挑战

533・Concat 3057・Push \ No newline at end of file +

Unshift 简单 #array

by jiangshan @jiangshanmeta

接受挑战    English 한국어

+ +实现类型版本的 ```Array.unshift```。 + +举例, + +```typescript +type Result = Unshift<[1, 2], 0> // [0, 1, 2,] +``` + + +
返回首页 分享你的解答 查看解答

相关挑战

533・Concat 3057・Push \ No newline at end of file diff --git a/questions/3060-easy-unshift/info.yml b/questions/03060-easy-unshift/info.yml similarity index 100% rename from questions/3060-easy-unshift/info.yml rename to questions/03060-easy-unshift/info.yml diff --git a/questions/3060-easy-unshift/template.ts b/questions/03060-easy-unshift/template.ts similarity index 100% rename from questions/3060-easy-unshift/template.ts rename to questions/03060-easy-unshift/template.ts diff --git a/questions/3060-easy-unshift/test-cases.ts b/questions/03060-easy-unshift/test-cases.ts similarity index 98% rename from questions/3060-easy-unshift/test-cases.ts rename to questions/03060-easy-unshift/test-cases.ts index 0a8740d86..a6b377842 100644 --- a/questions/3060-easy-unshift/test-cases.ts +++ b/questions/03060-easy-unshift/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, [1]>>, - Expect, [0, 1, 2 ]>>, - Expect, [boolean, '1', 2, '3']>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, [1]>>, + Expect, [0, 1, 2 ]>>, + Expect, [boolean, '1', 2, '3']>>, ] diff --git a/questions/3062-medium-shift/README.md b/questions/03062-medium-shift/README.md similarity index 86% rename from questions/3062-medium-shift/README.md rename to questions/03062-medium-shift/README.md index 50ab9b334..a393a5922 100644 --- a/questions/3062-medium-shift/README.md +++ b/questions/03062-medium-shift/README.md @@ -1,12 +1,12 @@

Shift medium #array

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Array.shift``` - -For example - -```typescript -type Result = Shift<[3, 2, 1]> // [2, 1] +Implement the type version of ```Array.shift``` + +For example + +```typescript +type Result = Shift<[3, 2, 1]> // [2, 1] ``` -
Back Share your Solutions Check out Solutions

Related Challenges

16・Pop \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

16・Pop \ No newline at end of file diff --git a/questions/3062-medium-shift/info.yml b/questions/03062-medium-shift/info.yml similarity index 100% rename from questions/3062-medium-shift/info.yml rename to questions/03062-medium-shift/info.yml diff --git a/questions/3062-medium-shift/template.ts b/questions/03062-medium-shift/template.ts similarity index 100% rename from questions/3062-medium-shift/template.ts rename to questions/03062-medium-shift/template.ts diff --git a/questions/3062-medium-shift/test-cases.ts b/questions/03062-medium-shift/test-cases.ts similarity index 98% rename from questions/3062-medium-shift/test-cases.ts rename to questions/03062-medium-shift/test-cases.ts index b394922e7..7e4760efa 100644 --- a/questions/3062-medium-shift/test-cases.ts +++ b/questions/03062-medium-shift/test-cases.ts @@ -1,7 +1,7 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, [2, 1]>>, - Expect, ['b', 'c', 'd']>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, [2, 1]>>, + Expect, ['b', 'c', 'd']>>, ] diff --git a/questions/3188-medium-tuple-to-nested-object/README.md b/questions/03188-medium-tuple-to-nested-object/README.md similarity index 59% rename from questions/3188-medium-tuple-to-nested-object/README.md rename to questions/03188-medium-tuple-to-nested-object/README.md index bf346d800..ec3a9c0b9 100644 --- a/questions/3188-medium-tuple-to-nested-object/README.md +++ b/questions/03188-medium-tuple-to-nested-object/README.md @@ -1,12 +1,12 @@

Tuple to Nested Object medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-Given a tuple type ```T``` that only contains string type, and a type ```U```, build an object recursively. - -```typescript -type a = TupleToNestedObject<['a'], string> // {a: string} -type b = TupleToNestedObject<['a', 'b'], number> // {a: {b: number}} -type c = TupleToNestedObject<[], boolean> // boolean. if the tuple is empty, just return the U type +Given a tuple type ```T``` that only contains string type, and a type ```U```, build an object recursively. + +```typescript +type a = TupleToNestedObject<['a'], string> // {a: string} +type b = TupleToNestedObject<['a', 'b'], number> // {a: {b: number}} +type c = TupleToNestedObject<[], boolean> // boolean. if the tuple is empty, just return the U type ``` -
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

10・Tuple to Union 11・Tuple to Object 472・Tuple to Enum Object 730・Union to Tuple \ No newline at end of file diff --git a/questions/3188-medium-tuple-to-nested-object/info.yml b/questions/03188-medium-tuple-to-nested-object/info.yml similarity index 100% rename from questions/3188-medium-tuple-to-nested-object/info.yml rename to questions/03188-medium-tuple-to-nested-object/info.yml diff --git a/questions/3188-medium-tuple-to-nested-object/template.ts b/questions/03188-medium-tuple-to-nested-object/template.ts similarity index 100% rename from questions/3188-medium-tuple-to-nested-object/template.ts rename to questions/03188-medium-tuple-to-nested-object/template.ts diff --git a/questions/3188-medium-tuple-to-nested-object/test-cases.ts b/questions/03188-medium-tuple-to-nested-object/test-cases.ts similarity index 98% rename from questions/3188-medium-tuple-to-nested-object/test-cases.ts rename to questions/03188-medium-tuple-to-nested-object/test-cases.ts index 50a920578..27d5fd0c2 100644 --- a/questions/3188-medium-tuple-to-nested-object/test-cases.ts +++ b/questions/03188-medium-tuple-to-nested-object/test-cases.ts @@ -1,9 +1,9 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, { a: string }>>, - Expect, { a: { b: number } }>>, - Expect, { a: { b: { c: boolean } } }>>, - Expect, boolean>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, { a: string }>>, + Expect, { a: { b: number } }>>, + Expect, { a: { b: { c: boolean } } }>>, + Expect, boolean>>, ] diff --git a/questions/3192-medium-reverse/README.md b/questions/03192-medium-reverse/README.md similarity index 99% rename from questions/3192-medium-reverse/README.md rename to questions/03192-medium-reverse/README.md index 8f57b0e9d..b2a3c383f 100644 --- a/questions/3192-medium-reverse/README.md +++ b/questions/03192-medium-reverse/README.md @@ -1,12 +1,12 @@

Reverse medium #tuple

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Array.reverse``` - -For example: - -```typescript -type a = Reverse<['a', 'b']> // ['b', 'a'] -type b = Reverse<['a', 'b', 'c']> // ['c', 'b', 'a'] +Implement the type version of ```Array.reverse``` + +For example: + +```typescript +type a = Reverse<['a', 'b']> // ['b', 'a'] +type b = Reverse<['a', 'b', 'c']> // ['c', 'b', 'a'] ``` diff --git a/questions/3192-medium-reverse/info.yml b/questions/03192-medium-reverse/info.yml similarity index 100% rename from questions/3192-medium-reverse/info.yml rename to questions/03192-medium-reverse/info.yml diff --git a/questions/3192-medium-reverse/template.ts b/questions/03192-medium-reverse/template.ts similarity index 100% rename from questions/3192-medium-reverse/template.ts rename to questions/03192-medium-reverse/template.ts diff --git a/questions/3192-medium-reverse/test-cases.ts b/questions/03192-medium-reverse/test-cases.ts similarity index 98% rename from questions/3192-medium-reverse/test-cases.ts rename to questions/03192-medium-reverse/test-cases.ts index c9fe6f1c5..d8f88075e 100644 --- a/questions/3192-medium-reverse/test-cases.ts +++ b/questions/03192-medium-reverse/test-cases.ts @@ -1,7 +1,7 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, ['b', 'a']>>, - Expect, ['c', 'b', 'a']>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, ['b', 'a']>>, + Expect, ['c', 'b', 'a']>>, ] diff --git a/questions/3196-medium-flip-arguments/README.md b/questions/03196-medium-flip-arguments/README.md similarity index 87% rename from questions/3196-medium-flip-arguments/README.md rename to questions/03196-medium-flip-arguments/README.md index 571177b79..cb05ced0a 100644 --- a/questions/3196-medium-flip-arguments/README.md +++ b/questions/03196-medium-flip-arguments/README.md @@ -1,15 +1,15 @@

Flip Arguments medium #arguments

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of lodash's ```_.flip```. - -Type ```FlipArguments``` requires function type ```T``` and returns a new function type which has the same return type of T but reversed parameters. - -For example: - -```typescript -type Flipped = FlipArguments<(arg0: string, arg1: number, arg2: boolean) => void> -// (arg0: boolean, arg1: number, arg2: string) => void +Implement the type version of lodash's ```_.flip```. + +Type ```FlipArguments``` requires function type ```T``` and returns a new function type which has the same return type of T but reversed parameters. + +For example: + +```typescript +type Flipped = FlipArguments<(arg0: string, arg1: number, arg2: boolean) => void> +// (arg0: boolean, arg1: number, arg2: string) => void ``` -
Back Share your Solutions Check out Solutions

Related Challenges

3192・Reverse \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

3192・Reverse \ No newline at end of file diff --git a/questions/3196-medium-flip-arguments/info.yml b/questions/03196-medium-flip-arguments/info.yml similarity index 100% rename from questions/3196-medium-flip-arguments/info.yml rename to questions/03196-medium-flip-arguments/info.yml diff --git a/questions/3196-medium-flip-arguments/template.ts b/questions/03196-medium-flip-arguments/template.ts similarity index 100% rename from questions/3196-medium-flip-arguments/template.ts rename to questions/03196-medium-flip-arguments/template.ts diff --git a/questions/3196-medium-flip-arguments/test-cases.ts b/questions/03196-medium-flip-arguments/test-cases.ts similarity index 98% rename from questions/3196-medium-flip-arguments/test-cases.ts rename to questions/03196-medium-flip-arguments/test-cases.ts index 91e04f17d..8dabedbcf 100644 --- a/questions/3196-medium-flip-arguments/test-cases.ts +++ b/questions/03196-medium-flip-arguments/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect boolean>, () => boolean>>, - Expect number>, (foo: string) => number>>, - Expect void>, (arg0: boolean, arg1: number, arg2: string) => void>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect boolean>, () => boolean>>, + Expect number>, (foo: string) => number>>, + Expect void>, (arg0: boolean, arg1: number, arg2: string) => void>>, ] diff --git a/questions/3243-medium-flattendepth/README.md b/questions/03243-medium-flattendepth/README.md similarity index 87% rename from questions/3243-medium-flattendepth/README.md rename to questions/03243-medium-flattendepth/README.md index 2c3bcd1f1..b2e65a6ec 100644 --- a/questions/3243-medium-flattendepth/README.md +++ b/questions/03243-medium-flattendepth/README.md @@ -1,15 +1,15 @@

FlattenDepth medium #array

by jiangshan @jiangshanmeta

Take the Challenge

-Recursively flatten array up to depth times. - -For example: - -```typescript -type a = FlattenDepth<[1, 2, [3, 4], [[[5]]]], 2> // [1, 2, 3, 4, [5]]. flattern 2 times -type b = FlattenDepth<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, [[5]]]. Depth defaults to be 1 -``` - +Recursively flatten array up to depth times. + +For example: + +```typescript +type a = FlattenDepth<[1, 2, [3, 4], [[[5]]]], 2> // [1, 2, 3, 4, [5]]. flattern 2 times +type b = FlattenDepth<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, [[5]]]. Depth defaults to be 1 +``` + If the depth is provided, it's guaranteed to be positive integer. -
Back Share your Solutions Check out Solutions

Related Challenges

459・Flatten \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

459・Flatten \ No newline at end of file diff --git a/questions/3243-medium-flattendepth/info.yml b/questions/03243-medium-flattendepth/info.yml similarity index 100% rename from questions/3243-medium-flattendepth/info.yml rename to questions/03243-medium-flattendepth/info.yml diff --git a/questions/3243-medium-flattendepth/template.ts b/questions/03243-medium-flattendepth/template.ts similarity index 100% rename from questions/3243-medium-flattendepth/template.ts rename to questions/03243-medium-flattendepth/template.ts diff --git a/questions/3243-medium-flattendepth/test-cases.ts b/questions/03243-medium-flattendepth/test-cases.ts similarity index 98% rename from questions/3243-medium-flattendepth/test-cases.ts rename to questions/03243-medium-flattendepth/test-cases.ts index 34283aed4..7f4dbf6e3 100644 --- a/questions/3243-medium-flattendepth/test-cases.ts +++ b/questions/03243-medium-flattendepth/test-cases.ts @@ -1,12 +1,12 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [1, 2, 3, 4]>>, - Expect, [1, 2]>>, - Expect, [1, 2, 3, 4, [5]]>>, - Expect, [1, 2, 3, 4, [[5]]]>>, - Expect, [1, 2, 3, 4, [5]]>>, - Expect, [1, 2, 3, 4, 5]>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [1, 2, 3, 4]>>, + Expect, [1, 2]>>, + Expect, [1, 2, 3, 4, [5]]>>, + Expect, [1, 2, 3, 4, [[5]]]>>, + Expect, [1, 2, 3, 4, [5]]>>, + Expect, [1, 2, 3, 4, 5]>>, ] diff --git a/questions/3312-easy-parameters/README.ko.md b/questions/03312-easy-parameters/README.ko.md similarity index 100% rename from questions/3312-easy-parameters/README.ko.md rename to questions/03312-easy-parameters/README.ko.md diff --git a/questions/3312-easy-parameters/README.md b/questions/03312-easy-parameters/README.md similarity index 100% rename from questions/3312-easy-parameters/README.md rename to questions/03312-easy-parameters/README.md diff --git a/questions/3312-easy-parameters/README.zh-CN.md b/questions/03312-easy-parameters/README.zh-CN.md similarity index 100% rename from questions/3312-easy-parameters/README.zh-CN.md rename to questions/03312-easy-parameters/README.zh-CN.md diff --git a/questions/3312-easy-parameters/info.yml b/questions/03312-easy-parameters/info.yml similarity index 100% rename from questions/3312-easy-parameters/info.yml rename to questions/03312-easy-parameters/info.yml diff --git a/questions/3312-easy-parameters/template.ts b/questions/03312-easy-parameters/template.ts similarity index 100% rename from questions/3312-easy-parameters/template.ts rename to questions/03312-easy-parameters/template.ts diff --git a/questions/3312-easy-parameters/test-cases.ts b/questions/03312-easy-parameters/test-cases.ts similarity index 97% rename from questions/3312-easy-parameters/test-cases.ts rename to questions/03312-easy-parameters/test-cases.ts index 9d5cd11c7..ecaaf156a 100644 --- a/questions/3312-easy-parameters/test-cases.ts +++ b/questions/03312-easy-parameters/test-cases.ts @@ -1,11 +1,11 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -const foo = (arg1: string, arg2: number): void => {} -const bar = (arg1: boolean, arg2: { a: 'A' }): void => {} -const baz = (): void => {} - -type cases = [ - Expect, [string, number]>>, - Expect, [boolean, { a: 'A' }]>>, - Expect, []>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +const foo = (arg1: string, arg2: number): void => {} +const bar = (arg1: boolean, arg2: { a: 'A' }): void => {} +const baz = (): void => {} + +type cases = [ + Expect, [string, number]>>, + Expect, [boolean, { a: 'A' }]>>, + Expect, []>>, +] diff --git a/questions/3326-medium-bem-style-string/README.md b/questions/03326-medium-bem-style-string/README.md similarity index 99% rename from questions/3326-medium-bem-style-string/README.md rename to questions/03326-medium-bem-style-string/README.md index 64ceef78d..7b4d9457f 100644 --- a/questions/3326-medium-bem-style-string/README.md +++ b/questions/03326-medium-bem-style-string/README.md @@ -1,9 +1,9 @@

BEM style string medium #template-literal #union #tuple

by Songhn @songhn233

Take the Challenge

-The Block, Element, Modifier methodology (BEM) is a popular naming convention for classes in CSS. - -For example, the block component would be represented as `btn`, element that depends upon the block would be represented as `btn__price`, modifier that changes the style of the block would be represented as `btn--big` or `btn__price--warning`. - +The Block, Element, Modifier methodology (BEM) is a popular naming convention for classes in CSS. + +For example, the block component would be represented as `btn`, element that depends upon the block would be represented as `btn__price`, modifier that changes the style of the block would be represented as `btn--big` or `btn__price--warning`. + Implement `BEM` which generate string union from these three parameters. Where `B` is a string literal, `E` and `M` are string arrays (can be empty). diff --git a/questions/3326-medium-bem-style-string/info.yml b/questions/03326-medium-bem-style-string/info.yml similarity index 100% rename from questions/3326-medium-bem-style-string/info.yml rename to questions/03326-medium-bem-style-string/info.yml diff --git a/questions/3326-medium-bem-style-string/template.ts b/questions/03326-medium-bem-style-string/template.ts similarity index 100% rename from questions/3326-medium-bem-style-string/template.ts rename to questions/03326-medium-bem-style-string/template.ts diff --git a/questions/3326-medium-bem-style-string/test-cases.ts b/questions/03326-medium-bem-style-string/test-cases.ts similarity index 98% rename from questions/3326-medium-bem-style-string/test-cases.ts rename to questions/03326-medium-bem-style-string/test-cases.ts index e28bba5dc..8a0e9468a 100644 --- a/questions/3326-medium-bem-style-string/test-cases.ts +++ b/questions/03326-medium-bem-style-string/test-cases.ts @@ -1,7 +1,7 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'btn__price'>>, - Expect, 'btn__price--warning' | 'btn__price--success' >>, - Expect, 'btn--small' | 'btn--medium' | 'btn--large' >>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'btn__price'>>, + Expect, 'btn__price--warning' | 'btn__price--success' >>, + Expect, 'btn--small' | 'btn--medium' | 'btn--large' >>, ] diff --git a/questions/3376-medium-inordertraversal/README.md b/questions/03376-medium-inordertraversal/README.md similarity index 98% rename from questions/3376-medium-inordertraversal/README.md rename to questions/03376-medium-inordertraversal/README.md index 4cf9015ac..ecaf69ed7 100644 --- a/questions/3376-medium-inordertraversal/README.md +++ b/questions/03376-medium-inordertraversal/README.md @@ -1,25 +1,25 @@

InorderTraversal medium #object

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of binary tree inorder traversal. - -For example: - -```typescript -const tree1 = { - val: 1, - left: null, - right: { - val: 2, - left: { - val: 3, - left: null, - right: null, - }, - right: null, - }, -} as const - -type A = InorderTraversal // [1, 3, 2] +Implement the type version of binary tree inorder traversal. + +For example: + +```typescript +const tree1 = { + val: 1, + left: null, + right: { + val: 2, + left: { + val: 3, + left: null, + right: null, + }, + right: null, + }, +} as const + +type A = InorderTraversal // [1, 3, 2] ``` diff --git a/questions/3376-medium-inordertraversal/info.yml b/questions/03376-medium-inordertraversal/info.yml similarity index 100% rename from questions/3376-medium-inordertraversal/info.yml rename to questions/03376-medium-inordertraversal/info.yml diff --git a/questions/3376-medium-inordertraversal/template.ts b/questions/03376-medium-inordertraversal/template.ts similarity index 96% rename from questions/3376-medium-inordertraversal/template.ts rename to questions/03376-medium-inordertraversal/template.ts index e7211bd5d..06fb722ca 100644 --- a/questions/3376-medium-inordertraversal/template.ts +++ b/questions/03376-medium-inordertraversal/template.ts @@ -1,6 +1,6 @@ -interface TreeNode { - val: number - left: TreeNode | null - right: TreeNode | null -} +interface TreeNode { + val: number + left: TreeNode | null + right: TreeNode | null +} type InorderTraversal = any diff --git a/questions/3376-medium-inordertraversal/test-cases.ts b/questions/03376-medium-inordertraversal/test-cases.ts similarity index 94% rename from questions/3376-medium-inordertraversal/test-cases.ts rename to questions/03376-medium-inordertraversal/test-cases.ts index 7b80475d2..98343d70d 100644 --- a/questions/3376-medium-inordertraversal/test-cases.ts +++ b/questions/03376-medium-inordertraversal/test-cases.ts @@ -1,50 +1,50 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -const tree1 = { - val: 1, - left: null, - right: { - val: 2, - left: { - val: 3, - left: null, - right: null, - }, - right: null, - }, -} as const - -const tree2 = { - val: 1, - left: null, - right: null, -} as const - -const tree3 = { - val: 1, - left: { - val: 2, - left: null, - right: null, - }, - right: null, -} as const - -const tree4 = { - val: 1, - left: null, - right: { - val: 2, - left: null, - right: null, - }, -} as const - -type cases = [ - Expect, []>>, - Expect, [1, 3, 2]>>, - Expect, [1]>>, - Expect, [2, 1]>>, - Expect, [1, 2]>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +const tree1 = { + val: 1, + left: null, + right: { + val: 2, + left: { + val: 3, + left: null, + right: null, + }, + right: null, + }, +} as const + +const tree2 = { + val: 1, + left: null, + right: null, +} as const + +const tree3 = { + val: 1, + left: { + val: 2, + left: null, + right: null, + }, + right: null, +} as const + +const tree4 = { + val: 1, + left: null, + right: { + val: 2, + left: null, + right: null, + }, +} as const + +type cases = [ + Expect, []>>, + Expect, [1, 3, 2]>>, + Expect, [1]>>, + Expect, [2, 1]>>, + Expect, [1, 2]>>, ] diff --git a/questions/4037-hard-ispalindrome/README.md b/questions/04037-hard-ispalindrome/README.md similarity index 99% rename from questions/4037-hard-ispalindrome/README.md rename to questions/04037-hard-ispalindrome/README.md index ab2027bb7..59092b3ef 100644 --- a/questions/4037-hard-ispalindrome/README.md +++ b/questions/04037-hard-ispalindrome/README.md @@ -1,12 +1,12 @@

IsPalindrome hard #string

by jiangshan @jiangshanmeta

Take the Challenge

-Implement type ```IsPalindrome``` to check whether a string or number is palindrome. - -For example: - -```typescript -IsPalindrome<'abc'> // false -IsPalindrome<121> // true +Implement type ```IsPalindrome``` to check whether a string or number is palindrome. + +For example: + +```typescript +IsPalindrome<'abc'> // false +IsPalindrome<121> // true ``` diff --git a/questions/4037-hard-ispalindrome/info.yml b/questions/04037-hard-ispalindrome/info.yml similarity index 100% rename from questions/4037-hard-ispalindrome/info.yml rename to questions/04037-hard-ispalindrome/info.yml diff --git a/questions/4037-hard-ispalindrome/template.ts b/questions/04037-hard-ispalindrome/template.ts similarity index 100% rename from questions/4037-hard-ispalindrome/template.ts rename to questions/04037-hard-ispalindrome/template.ts diff --git a/questions/4037-hard-ispalindrome/test-cases.ts b/questions/04037-hard-ispalindrome/test-cases.ts similarity index 97% rename from questions/4037-hard-ispalindrome/test-cases.ts rename to questions/04037-hard-ispalindrome/test-cases.ts index 20362737a..dbc2d69db 100644 --- a/questions/4037-hard-ispalindrome/test-cases.ts +++ b/questions/04037-hard-ispalindrome/test-cases.ts @@ -1,10 +1,10 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, false>>, - Expect, true>>, - Expect, false>>, - Expect, true>>, - Expect, false>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, false>>, + Expect, true>>, + Expect, false>>, + Expect, true>>, + Expect, false>>, ] diff --git a/questions/4179-medium-flip/README.md b/questions/04179-medium-flip/README.md similarity index 99% rename from questions/4179-medium-flip/README.md rename to questions/04179-medium-flip/README.md index 5d3d6264a..b39bb07e0 100644 --- a/questions/4179-medium-flip/README.md +++ b/questions/04179-medium-flip/README.md @@ -1,13 +1,13 @@

Flip medium #object

by Farhan Kathawala @kathawala

Take the Challenge

-Implement the type of `just-flip-object`. Examples: - -```typescript -Flip<{ a: "x", b: "y", c: "z" }>; // {x: 'a', y: 'b', z: 'c'} -Flip<{ a: 1, b: 2, c: 3 }>; // {1: 'a', 2: 'b', 3: 'c'} -flip<{ a: false, b: true }>; // {false: 'a', true: 'b'} -``` - +Implement the type of `just-flip-object`. Examples: + +```typescript +Flip<{ a: "x", b: "y", c: "z" }>; // {x: 'a', y: 'b', z: 'c'} +Flip<{ a: 1, b: 2, c: 3 }>; // {1: 'a', 2: 'b', 3: 'c'} +flip<{ a: false, b: true }>; // {false: 'a', true: 'b'} +``` + No need to support nested objects and values which cannot be object keys such as arrays diff --git a/questions/4179-medium-flip/info.yml b/questions/04179-medium-flip/info.yml similarity index 100% rename from questions/4179-medium-flip/info.yml rename to questions/04179-medium-flip/info.yml diff --git a/questions/4179-medium-flip/template.ts b/questions/04179-medium-flip/template.ts similarity index 100% rename from questions/4179-medium-flip/template.ts rename to questions/04179-medium-flip/template.ts diff --git a/questions/4179-medium-flip/test-cases.ts b/questions/04179-medium-flip/test-cases.ts similarity index 98% rename from questions/4179-medium-flip/test-cases.ts rename to questions/04179-medium-flip/test-cases.ts index 2f94cdf40..c721e0e68 100644 --- a/questions/4179-medium-flip/test-cases.ts +++ b/questions/04179-medium-flip/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect>>, - Expect>>, - Expect>>, - Expect>>, +import type { Equal, Expect, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect>>, + Expect>>, + Expect>>, + Expect>>, ] diff --git a/questions/4182-medium-fibonacci-sequence/README.md b/questions/04182-medium-fibonacci-sequence/README.md similarity index 100% rename from questions/4182-medium-fibonacci-sequence/README.md rename to questions/04182-medium-fibonacci-sequence/README.md diff --git a/questions/4182-medium-fibonacci-sequence/README.zh-CN.md b/questions/04182-medium-fibonacci-sequence/README.zh-CN.md similarity index 99% rename from questions/4182-medium-fibonacci-sequence/README.zh-CN.md rename to questions/04182-medium-fibonacci-sequence/README.zh-CN.md index 28039d85d..be0116df7 100644 --- a/questions/4182-medium-fibonacci-sequence/README.zh-CN.md +++ b/questions/04182-medium-fibonacci-sequence/README.zh-CN.md @@ -1,14 +1,14 @@

斐波那契序列 中等

by windliang @wind-liang

接受挑战    English

-Implement a generic Fibonacci\ takes an number T and returns it's corresponding [Fibonacci number](https://en.wikipedia.org/wiki/Fibonacci_number). - -The sequence starts: -1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... - -For example -```js -type Result1 = Fibonacci<3> // 2 -type Result2 = Fibonacci<8> // 21 +Implement a generic Fibonacci\ takes an number T and returns it's corresponding [Fibonacci number](https://en.wikipedia.org/wiki/Fibonacci_number). + +The sequence starts: +1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... + +For example +```js +type Result1 = Fibonacci<3> // 2 +type Result2 = Fibonacci<8> // 21 ``` diff --git a/questions/4182-medium-fibonacci-sequence/info.yml b/questions/04182-medium-fibonacci-sequence/info.yml similarity index 100% rename from questions/4182-medium-fibonacci-sequence/info.yml rename to questions/04182-medium-fibonacci-sequence/info.yml diff --git a/questions/4182-medium-fibonacci-sequence/info.zh-CN.yml b/questions/04182-medium-fibonacci-sequence/info.zh-CN.yml similarity index 100% rename from questions/4182-medium-fibonacci-sequence/info.zh-CN.yml rename to questions/04182-medium-fibonacci-sequence/info.zh-CN.yml diff --git a/questions/4182-medium-fibonacci-sequence/template.ts b/questions/04182-medium-fibonacci-sequence/template.ts similarity index 100% rename from questions/4182-medium-fibonacci-sequence/template.ts rename to questions/04182-medium-fibonacci-sequence/template.ts diff --git a/questions/4182-medium-fibonacci-sequence/test-cases.ts b/questions/04182-medium-fibonacci-sequence/test-cases.ts similarity index 96% rename from questions/4182-medium-fibonacci-sequence/test-cases.ts rename to questions/04182-medium-fibonacci-sequence/test-cases.ts index 7e0de5bc4..29897aff2 100644 --- a/questions/4182-medium-fibonacci-sequence/test-cases.ts +++ b/questions/04182-medium-fibonacci-sequence/test-cases.ts @@ -1,6 +1,6 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 2>>, - Expect, 21>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 2>>, + Expect, 21>>, ] diff --git a/questions/4260-medium-nomiwase/README.ja.md b/questions/04260-medium-nomiwase/README.ja.md similarity index 99% rename from questions/4260-medium-nomiwase/README.ja.md rename to questions/04260-medium-nomiwase/README.ja.md index 085bbb848..16274c1ba 100644 --- a/questions/4260-medium-nomiwase/README.ja.md +++ b/questions/04260-medium-nomiwase/README.ja.md @@ -1,13 +1,13 @@

文字の組み合わせ 中級

by 蛭子屋双六 @sugoroku-y

挑戦する    English

-指定された文字列に含まれる文字をそれぞれ最大で1度だけ使った文字列のすべての組み合わせの型`AllCombinations`を実装します。 - -例えば - -```ts - -type AllCombinations_ABC = AllCombinations<'ABC'>; -// should be '' | 'A' | 'B' | 'C' | 'AB' | 'AC' | 'BA' | 'BC' | 'CA' | 'CB' | 'ABC' | 'ACB' | 'BAC' | 'BCA' | 'CAB' | 'CBA' +指定された文字列に含まれる文字をそれぞれ最大で1度だけ使った文字列のすべての組み合わせの型`AllCombinations`を実装します。 + +例えば + +```ts + +type AllCombinations_ABC = AllCombinations<'ABC'>; +// should be '' | 'A' | 'B' | 'C' | 'AB' | 'AC' | 'BA' | 'BC' | 'CA' | 'CB' | 'ABC' | 'ACB' | 'BAC' | 'BCA' | 'CAB' | 'CBA' ``` diff --git a/questions/4260-medium-nomiwase/README.md b/questions/04260-medium-nomiwase/README.md similarity index 100% rename from questions/4260-medium-nomiwase/README.md rename to questions/04260-medium-nomiwase/README.md diff --git a/questions/4260-medium-nomiwase/info.ja.yml b/questions/04260-medium-nomiwase/info.ja.yml similarity index 100% rename from questions/4260-medium-nomiwase/info.ja.yml rename to questions/04260-medium-nomiwase/info.ja.yml diff --git a/questions/4260-medium-nomiwase/info.yml b/questions/04260-medium-nomiwase/info.yml similarity index 100% rename from questions/4260-medium-nomiwase/info.yml rename to questions/04260-medium-nomiwase/info.yml diff --git a/questions/4260-medium-nomiwase/template.ts b/questions/04260-medium-nomiwase/template.ts similarity index 100% rename from questions/4260-medium-nomiwase/template.ts rename to questions/04260-medium-nomiwase/template.ts diff --git a/questions/4260-medium-nomiwase/test-cases.ts b/questions/04260-medium-nomiwase/test-cases.ts similarity index 99% rename from questions/4260-medium-nomiwase/test-cases.ts rename to questions/04260-medium-nomiwase/test-cases.ts index 16ed32682..894e067ea 100644 --- a/questions/4260-medium-nomiwase/test-cases.ts +++ b/questions/04260-medium-nomiwase/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, ''>>, - Expect, '' | 'A'>>, - Expect, '' | 'A' | 'B' | 'AB' | 'BA'>>, - Expect, '' | 'A' | 'B' | 'C' | 'AB' | 'AC' | 'BA' | 'BC' | 'CA' | 'CB' | 'ABC' | 'ACB' | 'BAC' | 'BCA' | 'CAB' | 'CBA'>>, - Expect, '' | 'A' | 'B' | 'C' | 'D' | 'AB' | 'AC' | 'AD' | 'BA' | 'BC' | 'BD' | 'CA' | 'CB' | 'CD' | 'DA' | 'DB' | 'DC' | 'ABC' | 'ABD' | 'ACB' | 'ACD' | 'ADB' | 'ADC' | 'BAC' | 'BAD' | 'BCA' | 'BCD' | 'BDA' | 'BDC' | 'CAB' | 'CAD' | 'CBA' | 'CBD' | 'CDA' | 'CDB' | 'DAB' | 'DAC' | 'DBA' | 'DBC' | 'DCA' | 'DCB' | 'ABCD' | 'ABDC' | 'ACBD' | 'ACDB' | 'ADBC' | 'ADCB' | 'BACD' | 'BADC' | 'BCAD' | 'BCDA' | 'BDAC' | 'BDCA' | 'CABD' | 'CADB' | 'CBAD' | 'CBDA' | 'CDAB' | 'CDBA' | 'DABC' | 'DACB' | 'DBAC' | 'DBCA' | 'DCAB' | 'DCBA'>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, ''>>, + Expect, '' | 'A'>>, + Expect, '' | 'A' | 'B' | 'AB' | 'BA'>>, + Expect, '' | 'A' | 'B' | 'C' | 'AB' | 'AC' | 'BA' | 'BC' | 'CA' | 'CB' | 'ABC' | 'ACB' | 'BAC' | 'BCA' | 'CAB' | 'CBA'>>, + Expect, '' | 'A' | 'B' | 'C' | 'D' | 'AB' | 'AC' | 'AD' | 'BA' | 'BC' | 'BD' | 'CA' | 'CB' | 'CD' | 'DA' | 'DB' | 'DC' | 'ABC' | 'ABD' | 'ACB' | 'ACD' | 'ADB' | 'ADC' | 'BAC' | 'BAD' | 'BCA' | 'BCD' | 'BDA' | 'BDC' | 'CAB' | 'CAD' | 'CBA' | 'CBD' | 'CDA' | 'CDB' | 'DAB' | 'DAC' | 'DBA' | 'DBC' | 'DCA' | 'DCB' | 'ABCD' | 'ABDC' | 'ACBD' | 'ACDB' | 'ADBC' | 'ADCB' | 'BACD' | 'BADC' | 'BCAD' | 'BCDA' | 'BDAC' | 'BDCA' | 'CABD' | 'CADB' | 'CBAD' | 'CBDA' | 'CDAB' | 'CDBA' | 'DABC' | 'DACB' | 'DBAC' | 'DBCA' | 'DCAB' | 'DCBA'>>, ] diff --git a/questions/4425-medium-greater-than/README.md b/questions/04425-medium-greater-than/README.md similarity index 99% rename from questions/4425-medium-greater-than/README.md rename to questions/04425-medium-greater-than/README.md index d026a592c..8d2e1a84a 100644 --- a/questions/4425-medium-greater-than/README.md +++ b/questions/04425-medium-greater-than/README.md @@ -1,16 +1,16 @@

Greater Than medium #array

by ch3cknull @ch3cknull

Take the Challenge

-In This Challenge, You should implement a type `GreaterThan` like `T > U` - -Negative numbers do not need to be considered. - -For example - -```ts -GreaterThan<2, 1> //should be true -GreaterThan<1, 1> //should be false -``` - +In This Challenge, You should implement a type `GreaterThan` like `T > U` + +Negative numbers do not need to be considered. + +For example + +```ts +GreaterThan<2, 1> //should be true +GreaterThan<1, 1> //should be false +``` + Good Luck! diff --git a/questions/4425-medium-greater-than/info.yml b/questions/04425-medium-greater-than/info.yml similarity index 100% rename from questions/4425-medium-greater-than/info.yml rename to questions/04425-medium-greater-than/info.yml diff --git a/questions/4425-medium-greater-than/template.ts b/questions/04425-medium-greater-than/template.ts similarity index 100% rename from questions/4425-medium-greater-than/template.ts rename to questions/04425-medium-greater-than/template.ts diff --git a/questions/4425-medium-greater-than/test-cases.ts b/questions/04425-medium-greater-than/test-cases.ts similarity index 97% rename from questions/4425-medium-greater-than/test-cases.ts rename to questions/04425-medium-greater-than/test-cases.ts index 5889753a3..aacef4cea 100644 --- a/questions/4425-medium-greater-than/test-cases.ts +++ b/questions/04425-medium-greater-than/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, true>>, - Expect, false>>, - Expect, false>>, - Expect, false>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, true>>, + Expect, false>>, + Expect, false>>, + Expect, false>>, +] diff --git a/questions/4471-medium-zip/README.md b/questions/04471-medium-zip/README.md similarity index 99% rename from questions/4471-medium-zip/README.md rename to questions/04471-medium-zip/README.md index 5685aab19..3cfac5675 100644 --- a/questions/4471-medium-zip/README.md +++ b/questions/04471-medium-zip/README.md @@ -1,8 +1,8 @@

Zip medium #tuple

by キリサメ qianxi @qianxi0410

Take the Challenge

-In This Challenge, You should implement a type `Zip`, T and U must be `Tuple` -```ts -type exp = Zip<[1, 2], [true, false]> // expected to be [[1, true], [2, false]] +In This Challenge, You should implement a type `Zip`, T and U must be `Tuple` +```ts +type exp = Zip<[1, 2], [true, false]> // expected to be [[1, true], [2, false]] ``` diff --git a/questions/4471-medium-zip/info.yml b/questions/04471-medium-zip/info.yml similarity index 100% rename from questions/4471-medium-zip/info.yml rename to questions/04471-medium-zip/info.yml diff --git a/questions/4471-medium-zip/template.ts b/questions/04471-medium-zip/template.ts similarity index 100% rename from questions/4471-medium-zip/template.ts rename to questions/04471-medium-zip/template.ts diff --git a/questions/4471-medium-zip/test-cases.ts b/questions/04471-medium-zip/test-cases.ts similarity index 97% rename from questions/4471-medium-zip/test-cases.ts rename to questions/04471-medium-zip/test-cases.ts index 70daef53a..17ba3357a 100644 --- a/questions/4471-medium-zip/test-cases.ts +++ b/questions/04471-medium-zip/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [[1, true], [2, false]]>>, - Expect, [[1, '1'], [2, '2']]>>, - Expect, []>>, - Expect, [[[1, 2], 3]]>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [[1, true], [2, false]]>>, + Expect, [[1, '1'], [2, '2']]>>, + Expect, []>>, + Expect, [[[1, 2], 3]]>>, ] diff --git a/questions/4484-medium-istuple/README.md b/questions/04484-medium-istuple/README.md similarity index 67% rename from questions/4484-medium-istuple/README.md rename to questions/04484-medium-istuple/README.md index f9a9da407..95806319f 100644 --- a/questions/4484-medium-istuple/README.md +++ b/questions/04484-medium-istuple/README.md @@ -1,14 +1,14 @@

IsTuple medium #tuple

by jiangshan @jiangshanmeta

Take the Challenge

-Implement a type ```IsTuple```, which takes an input type ```T``` and returns whether ```T``` is tuple type. - -For example: - -```typescript -type case1 = IsTuple<[number]> // true -type case2 = IsTuple // true -type case3 = IsTuple // false +Implement a type ```IsTuple```, which takes an input type ```T``` and returns whether ```T``` is tuple type. + +For example: + +```typescript +type case1 = IsTuple<[number]> // true +type case2 = IsTuple // true +type case3 = IsTuple // false ``` -
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 1097・IsUnion 223・IsAny \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

1042・IsNever 1097・IsUnion 223・IsAny \ No newline at end of file diff --git a/questions/4484-medium-istuple/info.yml b/questions/04484-medium-istuple/info.yml similarity index 100% rename from questions/4484-medium-istuple/info.yml rename to questions/04484-medium-istuple/info.yml diff --git a/questions/4484-medium-istuple/template.ts b/questions/04484-medium-istuple/template.ts similarity index 100% rename from questions/4484-medium-istuple/template.ts rename to questions/04484-medium-istuple/template.ts diff --git a/questions/4484-medium-istuple/test-cases.ts b/questions/04484-medium-istuple/test-cases.ts similarity index 97% rename from questions/4484-medium-istuple/test-cases.ts rename to questions/04484-medium-istuple/test-cases.ts index 66fe633c0..ed60121b0 100644 --- a/questions/4484-medium-istuple/test-cases.ts +++ b/questions/04484-medium-istuple/test-cases.ts @@ -1,10 +1,10 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, true>>, - Expect, true>>, - Expect, true>>, - Expect, false>>, - Expect, false>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, true>>, + Expect, true>>, + Expect, true>>, + Expect, false>>, + Expect, false>>, ] diff --git a/questions/4499-medium-chunk/README.md b/questions/04499-medium-chunk/README.md similarity index 99% rename from questions/4499-medium-chunk/README.md rename to questions/04499-medium-chunk/README.md index ea186f9bc..4bcf71075 100644 --- a/questions/4499-medium-chunk/README.md +++ b/questions/04499-medium-chunk/README.md @@ -1,12 +1,12 @@

Chunk medium #tuple

by キリサメ qianxi @qianxi0410

Take the Challenge

-Do you know `lodash`? `Chunk` is a very useful function in it, now let's implement it. -`Chunk` accepts two required type parameters, the `T` must be a `tuple`, and the `N` must be an `integer >=1` - -```ts -type exp1 = Chunk<[1, 2, 3], 2> // expected to be [[1, 2], [3]] -type exp2 = Chunk<[1, 2, 3], 4> // expected to be [[1, 2, 3]] -type exp3 = Chunk<[1, 2, 3], 1> // expected to be [[1], [2], [3]] +Do you know `lodash`? `Chunk` is a very useful function in it, now let's implement it. +`Chunk` accepts two required type parameters, the `T` must be a `tuple`, and the `N` must be an `integer >=1` + +```ts +type exp1 = Chunk<[1, 2, 3], 2> // expected to be [[1, 2], [3]] +type exp2 = Chunk<[1, 2, 3], 4> // expected to be [[1, 2, 3]] +type exp3 = Chunk<[1, 2, 3], 1> // expected to be [[1], [2], [3]] ``` diff --git a/questions/4499-medium-chunk/info.yml b/questions/04499-medium-chunk/info.yml similarity index 100% rename from questions/4499-medium-chunk/info.yml rename to questions/04499-medium-chunk/info.yml diff --git a/questions/4499-medium-chunk/template.ts b/questions/04499-medium-chunk/template.ts similarity index 100% rename from questions/4499-medium-chunk/template.ts rename to questions/04499-medium-chunk/template.ts diff --git a/questions/4499-medium-chunk/test-cases.ts b/questions/04499-medium-chunk/test-cases.ts similarity index 97% rename from questions/4499-medium-chunk/test-cases.ts rename to questions/04499-medium-chunk/test-cases.ts index a0bb18bf3..081594e4d 100644 --- a/questions/4499-medium-chunk/test-cases.ts +++ b/questions/04499-medium-chunk/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [[1], [2], [3]]>>, - Expect, [[1, 2], [3]]>>, - Expect, [[1, 2], [3, 4]]>>, - Expect, [[1, 2, 3, 4]]>>, - Expect, [[1, true], [2, false]]>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [[1], [2], [3]]>>, + Expect, [[1, 2], [3]]>>, + Expect, [[1, 2], [3, 4]]>>, + Expect, [[1, 2, 3, 4]]>>, + Expect, [[1, true], [2, false]]>>, ] diff --git a/questions/4518-medium-fill/README.md b/questions/04518-medium-fill/README.md similarity index 99% rename from questions/4518-medium-fill/README.md rename to questions/04518-medium-fill/README.md index 500a108b4..ae1deba35 100644 --- a/questions/4518-medium-fill/README.md +++ b/questions/04518-medium-fill/README.md @@ -1,12 +1,12 @@

Fill medium #tuple

by キリサメ qianxi @qianxi0410

Take the Challenge

-`Fill`, a common JavaScript function, now let us implement it with types. -`Fill`, as you can see,`Fill` accepts four types of parameters, of which `T` and `N` are required parameters, and `Start` and `End` are optional parameters. -The requirements for these parameters are: `T` must be a `tuple`, `N` can be any type of value, `Start` and `End` must be integers greater than or equal to 0. - -```ts -type exp = Fill<[1, 2, 3], 0> // expected to be [0, 0, 0] -``` +`Fill`, a common JavaScript function, now let us implement it with types. +`Fill`, as you can see,`Fill` accepts four types of parameters, of which `T` and `N` are required parameters, and `Start` and `End` are optional parameters. +The requirements for these parameters are: `T` must be a `tuple`, `N` can be any type of value, `Start` and `End` must be integers greater than or equal to 0. + +```ts +type exp = Fill<[1, 2, 3], 0> // expected to be [0, 0, 0] +``` In order to simulate the real function, the test may contain some boundary conditions, I hope you can enjoy it :) diff --git a/questions/4518-medium-fill/info.yml b/questions/04518-medium-fill/info.yml similarity index 100% rename from questions/4518-medium-fill/info.yml rename to questions/04518-medium-fill/info.yml diff --git a/questions/4518-medium-fill/template.ts b/questions/04518-medium-fill/template.ts similarity index 95% rename from questions/4518-medium-fill/template.ts rename to questions/04518-medium-fill/template.ts index 11d56cd60..d496d8ff4 100644 --- a/questions/4518-medium-fill/template.ts +++ b/questions/04518-medium-fill/template.ts @@ -1,6 +1,6 @@ -type Fill< - T extends unknown[], - N, - Start extends number = 0, - End extends number = T['length'], +type Fill< + T extends unknown[], + N, + Start extends number = 0, + End extends number = T['length'], > = any diff --git a/questions/4518-medium-fill/test-cases.ts b/questions/04518-medium-fill/test-cases.ts similarity index 97% rename from questions/4518-medium-fill/test-cases.ts rename to questions/04518-medium-fill/test-cases.ts index 81d26c645..e0c7f6ea2 100644 --- a/questions/4518-medium-fill/test-cases.ts +++ b/questions/04518-medium-fill/test-cases.ts @@ -1,14 +1,14 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, []>>, - Expect, [1, 2, 3]>>, - Expect, [1, 2, 3]>>, - Expect, [0, 0, 0]>>, - Expect, [true, true, true]>>, - Expect, [true, 2, 3]>>, - Expect, [1, true, true]>>, - Expect, [1, 2, 3]>>, - Expect, [true, true, true]>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, []>>, + Expect, [1, 2, 3]>>, + Expect, [1, 2, 3]>>, + Expect, [0, 0, 0]>>, + Expect, [true, true, true]>>, + Expect, [true, 2, 3]>>, + Expect, [1, true, true]>>, + Expect, [1, 2, 3]>>, + Expect, [true, true, true]>>, ] diff --git a/questions/4803-medium-trim-right/README.md b/questions/04803-medium-trim-right/README.md similarity index 76% rename from questions/4803-medium-trim-right/README.md rename to questions/04803-medium-trim-right/README.md index eb692ac0c..6bff705b7 100644 --- a/questions/4803-medium-trim-right/README.md +++ b/questions/04803-medium-trim-right/README.md @@ -1,12 +1,12 @@ -

Trim Right medium

by Yugang Cao @Talljack

Take the Challenge    简体中文

- -Implement `TrimRight` which takes an exact string type and returns a new string with the whitespace ending removed. - -For example: - -```ts -type Trimed = TrimRight<' Hello World '> // expected to be ' Hello World' -``` - - -
Back Share your Solutions Check out Solutions

Related Challenges

106・Trim Left 108・Trim \ No newline at end of file +

Trim Right medium

by Yugang Cao @Talljack

Take the Challenge    简体中文

+ +Implement `TrimRight` which takes an exact string type and returns a new string with the whitespace ending removed. + +For example: + +```ts +type Trimed = TrimRight<' Hello World '> // expected to be ' Hello World' +``` + + +
Back Share your Solutions Check out Solutions

Related Challenges

106・Trim Left 108・Trim \ No newline at end of file diff --git a/questions/4803-medium-trim-right/README.zh-CN.md b/questions/04803-medium-trim-right/README.zh-CN.md similarity index 76% rename from questions/4803-medium-trim-right/README.zh-CN.md rename to questions/04803-medium-trim-right/README.zh-CN.md index 09b16ce8c..5bbc51570 100644 --- a/questions/4803-medium-trim-right/README.zh-CN.md +++ b/questions/04803-medium-trim-right/README.zh-CN.md @@ -9,4 +9,4 @@ type Trimed = TrimLeft<' Hello World '> // 应推导出 ' Hello World' ``` -
返回首页 分享你的解答 查看解答

相关挑战

106・Trim Left 108・Trim \ No newline at end of file +
返回首页 分享你的解答 查看解答

相关挑战

106・Trim Left 108・Trim \ No newline at end of file diff --git a/questions/4803-medium-trim-right/info.yml b/questions/04803-medium-trim-right/info.yml similarity index 100% rename from questions/4803-medium-trim-right/info.yml rename to questions/04803-medium-trim-right/info.yml diff --git a/questions/4803-medium-trim-right/template.ts b/questions/04803-medium-trim-right/template.ts similarity index 100% rename from questions/4803-medium-trim-right/template.ts rename to questions/04803-medium-trim-right/template.ts diff --git a/questions/4803-medium-trim-right/test-cases.ts b/questions/04803-medium-trim-right/test-cases.ts similarity index 97% rename from questions/4803-medium-trim-right/test-cases.ts rename to questions/04803-medium-trim-right/test-cases.ts index b685293be..0cdc284fa 100644 --- a/questions/4803-medium-trim-right/test-cases.ts +++ b/questions/04803-medium-trim-right/test-cases.ts @@ -1,11 +1,11 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'str'>>, - Expect, 'str'>>, - Expect, 'str'>>, - Expect, ' str'>>, - Expect, ' foo bar'>>, - Expect, ''>>, - Expect, ''>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'str'>>, + Expect, 'str'>>, + Expect, 'str'>>, + Expect, ' str'>>, + Expect, ' foo bar'>>, + Expect, ''>>, + Expect, ''>>, +] diff --git a/questions/5117-medium-without/README.md b/questions/05117-medium-without/README.md similarity index 99% rename from questions/5117-medium-without/README.md rename to questions/05117-medium-without/README.md index ec760fb9b..214fb77cb 100644 --- a/questions/5117-medium-without/README.md +++ b/questions/05117-medium-without/README.md @@ -1,11 +1,11 @@ -

Without medium #union #array

by Pineapple @Pineapple0919

Take the Challenge    简体中文

- -Implement the type version of Lodash.without, Without takes an Array T, number or array U and returns an Array without the elements of U. - -```ts -type Res = Without<[1, 2], 1>; // expected to be [2] -type Res1 = Without<[1, 2, 4, 1, 5], [1, 2]>; // expected to be [4, 5] -type Res2 = Without<[2, 3, 2, 3, 2, 3, 2, 3], [2, 3]>; // expected to be [] -``` - -
Back Share your Solutions Check out Solutions +

Without medium #union #array

by Pineapple @Pineapple0919

Take the Challenge    简体中文

+ +Implement the type version of Lodash.without, Without takes an Array T, number or array U and returns an Array without the elements of U. + +```ts +type Res = Without<[1, 2], 1>; // expected to be [2] +type Res1 = Without<[1, 2, 4, 1, 5], [1, 2]>; // expected to be [4, 5] +type Res2 = Without<[2, 3, 2, 3, 2, 3, 2, 3], [2, 3]>; // expected to be [] +``` + +
Back Share your Solutions Check out Solutions diff --git a/questions/5117-medium-without/README.zh-CN.md b/questions/05117-medium-without/README.zh-CN.md similarity index 99% rename from questions/5117-medium-without/README.zh-CN.md rename to questions/05117-medium-without/README.zh-CN.md index 170829ebf..8a67259ee 100644 --- a/questions/5117-medium-without/README.zh-CN.md +++ b/questions/05117-medium-without/README.zh-CN.md @@ -1,13 +1,13 @@ -

去除数组指定元素 中等 #联合类型 #数组

by Pineapple @Pineapple0919

接受挑战    English

- -实现一个像 Lodash.without 函数一样的泛型 Without,它接收数组类型的 T 和数字或数组类型的 U 为参数,会返回一个去除 U 中元素的数组 T。 - -例如: - -```ts -type Res = Without<[1, 2], 1>; // expected to be [2] -type Res1 = Without<[1, 2, 4, 1, 5], [1, 2]>; // expected to be [4, 5] -type Res2 = Without<[2, 3, 2, 3, 2, 3, 2, 3], [2, 3]>; // expected to be [] -``` - -
返回首页 分享你的解答 查看解答 +

去除数组指定元素 中等 #联合类型 #数组

by Pineapple @Pineapple0919

接受挑战    English

+ +实现一个像 Lodash.without 函数一样的泛型 Without,它接收数组类型的 T 和数字或数组类型的 U 为参数,会返回一个去除 U 中元素的数组 T。 + +例如: + +```ts +type Res = Without<[1, 2], 1>; // expected to be [2] +type Res1 = Without<[1, 2, 4, 1, 5], [1, 2]>; // expected to be [4, 5] +type Res2 = Without<[2, 3, 2, 3, 2, 3, 2, 3], [2, 3]>; // expected to be [] +``` + +
返回首页 分享你的解答 查看解答 diff --git a/questions/5117-medium-without/info.yml b/questions/05117-medium-without/info.yml similarity index 100% rename from questions/5117-medium-without/info.yml rename to questions/05117-medium-without/info.yml diff --git a/questions/5117-medium-without/info.zh-CN.yml b/questions/05117-medium-without/info.zh-CN.yml similarity index 95% rename from questions/5117-medium-without/info.zh-CN.yml rename to questions/05117-medium-without/info.zh-CN.yml index 202ff8587..172c6e940 100644 --- a/questions/5117-medium-without/info.zh-CN.yml +++ b/questions/05117-medium-without/info.zh-CN.yml @@ -1,6 +1,6 @@ -difficulty: 中等 -title: 去除数组指定元素 -tags: 联合类型, 数组 -author: - github: Pineapple0919 - name: Pineapple +difficulty: 中等 +title: 去除数组指定元素 +tags: 联合类型, 数组 +author: + github: Pineapple0919 + name: Pineapple diff --git a/questions/5117-medium-without/template.ts b/questions/05117-medium-without/template.ts similarity index 100% rename from questions/5117-medium-without/template.ts rename to questions/05117-medium-without/template.ts diff --git a/questions/5117-medium-without/test-cases.ts b/questions/05117-medium-without/test-cases.ts similarity index 97% rename from questions/5117-medium-without/test-cases.ts rename to questions/05117-medium-without/test-cases.ts index ee4a045ae..573fd06a1 100644 --- a/questions/5117-medium-without/test-cases.ts +++ b/questions/05117-medium-without/test-cases.ts @@ -1,7 +1,7 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, [2]>>, - Expect, [4, 5]>>, - Expect, []>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, [2]>>, + Expect, [4, 5]>>, + Expect, []>>, ] diff --git a/questions/5140-medium-trunc/README.md b/questions/05140-medium-trunc/README.md similarity index 99% rename from questions/5140-medium-trunc/README.md rename to questions/05140-medium-trunc/README.md index 6aea6be92..f57190f0d 100644 --- a/questions/5140-medium-trunc/README.md +++ b/questions/05140-medium-trunc/README.md @@ -1,11 +1,11 @@

Trunc medium #template-literal

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Math.trunc```, which takes string or number and returns the integer part of a number by removing any fractional digits. - -For example: - -```typescript -type A = Trunc<12.34> // 12 +Implement the type version of ```Math.trunc```, which takes string or number and returns the integer part of a number by removing any fractional digits. + +For example: + +```typescript +type A = Trunc<12.34> // 12 ``` diff --git a/questions/5140-medium-trunc/info.yml b/questions/05140-medium-trunc/info.yml similarity index 100% rename from questions/5140-medium-trunc/info.yml rename to questions/05140-medium-trunc/info.yml diff --git a/questions/5140-medium-trunc/template.ts b/questions/05140-medium-trunc/template.ts similarity index 100% rename from questions/5140-medium-trunc/template.ts rename to questions/05140-medium-trunc/template.ts diff --git a/questions/5140-medium-trunc/test-cases.ts b/questions/05140-medium-trunc/test-cases.ts similarity index 97% rename from questions/5140-medium-trunc/test-cases.ts rename to questions/05140-medium-trunc/test-cases.ts index 96ed7ac1d..a4bb500c6 100644 --- a/questions/5140-medium-trunc/test-cases.ts +++ b/questions/05140-medium-trunc/test-cases.ts @@ -1,12 +1,12 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, '0'>>, - Expect, '1'>>, - Expect, '12'>>, - Expect, '-5'>>, - Expect, '1'>>, - Expect, '-10'>>, - Expect, '10'>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, '0'>>, + Expect, '1'>>, + Expect, '12'>>, + Expect, '-5'>>, + Expect, '1'>>, + Expect, '-10'>>, + Expect, '10'>>, ] diff --git a/questions/5153-medium-indexof/README.md b/questions/05153-medium-indexof/README.md similarity index 99% rename from questions/5153-medium-indexof/README.md rename to questions/05153-medium-indexof/README.md index a816724ef..949339e49 100644 --- a/questions/5153-medium-indexof/README.md +++ b/questions/05153-medium-indexof/README.md @@ -1,12 +1,12 @@ -

IndexOf medium #array

by Pineapple @Pineapple0919

Take the Challenge

- -Implement the type version of Array.indexOf, indexOf takes an Array T, any U and returns the index of the first U in Array T. - -```ts -type Res = IndexOf<[1, 2, 3], 2>; // expected to be 1 -type Res1 = IndexOf<[2,6, 3,8,4,1,7, 3,9], 3>; // expected to be 2 -type Res2 = IndexOf<[0, 0, 0], 2>; // expected to be -1 -``` - - +

IndexOf medium #array

by Pineapple @Pineapple0919

Take the Challenge

+ +Implement the type version of Array.indexOf, indexOf takes an Array T, any U and returns the index of the first U in Array T. + +```ts +type Res = IndexOf<[1, 2, 3], 2>; // expected to be 1 +type Res1 = IndexOf<[2,6, 3,8,4,1,7, 3,9], 3>; // expected to be 2 +type Res2 = IndexOf<[0, 0, 0], 2>; // expected to be -1 +``` + +
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/5153-medium-indexof/info.yml b/questions/05153-medium-indexof/info.yml similarity index 100% rename from questions/5153-medium-indexof/info.yml rename to questions/05153-medium-indexof/info.yml diff --git a/questions/5153-medium-indexof/template.ts b/questions/05153-medium-indexof/template.ts similarity index 100% rename from questions/5153-medium-indexof/template.ts rename to questions/05153-medium-indexof/template.ts diff --git a/questions/5153-medium-indexof/test-cases.ts b/questions/05153-medium-indexof/test-cases.ts similarity index 97% rename from questions/5153-medium-indexof/test-cases.ts rename to questions/05153-medium-indexof/test-cases.ts index 3810558d5..c3e9b3833 100644 --- a/questions/5153-medium-indexof/test-cases.ts +++ b/questions/05153-medium-indexof/test-cases.ts @@ -1,7 +1,7 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 1>>, - Expect, 2>>, - Expect, -1>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 1>>, + Expect, 2>>, + Expect, -1>>, ] diff --git a/questions/5181-hard-mutable-keys/README.md b/questions/05181-hard-mutable-keys/README.md similarity index 86% rename from questions/5181-hard-mutable-keys/README.md rename to questions/05181-hard-mutable-keys/README.md index 1848eba37..36539b5e7 100644 --- a/questions/5181-hard-mutable-keys/README.md +++ b/questions/05181-hard-mutable-keys/README.md @@ -1,13 +1,13 @@

Mutable Keys hard #utils

by Yugang Cao @Talljack

Take the Challenge

-Implement the advanced util type MutableKeys, which picks all the mutable (not readonly) keys into a union. - -For example: - -```ts -type Keys = MutableKeys<{ readonly foo: string; bar: number }>; -// expected to be “bar” +Implement the advanced util type MutableKeys, which picks all the mutable (not readonly) keys into a union. + +For example: + +```ts +type Keys = MutableKeys<{ readonly foo: string; bar: number }>; +// expected to be “bar” ``` -
Back Share your Solutions Check out Solutions

Related Challenges

2793・Mutable \ No newline at end of file +
Back Share your Solutions Check out Solutions

Related Challenges

2793・Mutable \ No newline at end of file diff --git a/questions/5181-hard-mutable-keys/info.yml b/questions/05181-hard-mutable-keys/info.yml similarity index 100% rename from questions/5181-hard-mutable-keys/info.yml rename to questions/05181-hard-mutable-keys/info.yml diff --git a/questions/5181-hard-mutable-keys/template.ts b/questions/05181-hard-mutable-keys/template.ts similarity index 100% rename from questions/5181-hard-mutable-keys/template.ts rename to questions/05181-hard-mutable-keys/template.ts diff --git a/questions/5181-hard-mutable-keys/test-cases.ts b/questions/05181-hard-mutable-keys/test-cases.ts similarity index 98% rename from questions/5181-hard-mutable-keys/test-cases.ts rename to questions/05181-hard-mutable-keys/test-cases.ts index aaebc0a10..5446b9393 100644 --- a/questions/5181-hard-mutable-keys/test-cases.ts +++ b/questions/05181-hard-mutable-keys/test-cases.ts @@ -1,8 +1,8 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 'a'>>, - Expect, 'a'>>, - Expect, 'a' | 'c' | 'd'>>, - Expect, never>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 'a'>>, + Expect, 'a'>>, + Expect, 'a' | 'c' | 'd'>>, + Expect, never>>, ] diff --git a/questions/5310-medium-join/README.md b/questions/05310-medium-join/README.md similarity index 99% rename from questions/5310-medium-join/README.md rename to questions/05310-medium-join/README.md index 5a1480b68..13f8372e9 100644 --- a/questions/5310-medium-join/README.md +++ b/questions/05310-medium-join/README.md @@ -1,12 +1,12 @@

Join medium #array

by Pineapple @Pineapple0919

Take the Challenge

-Implement the type version of Array.join, Join takes an Array T, string or number U and returns the Array T with U stitching up. - -```ts -type Res = Join<["a", "p", "p", "l", "e"], "-">; // expected to be 'a-p-p-l-e' -type Res1 = Join<["Hello", "World"], " ">; // expected to be 'Hello World' -type Res2 = Join<["2", "2", "2"], 1>; // expected to be '21212' -type Res3 = Join<["o"], "u">; // expected to be 'o' +Implement the type version of Array.join, Join takes an Array T, string or number U and returns the Array T with U stitching up. + +```ts +type Res = Join<["a", "p", "p", "l", "e"], "-">; // expected to be 'a-p-p-l-e' +type Res1 = Join<["Hello", "World"], " ">; // expected to be 'Hello World' +type Res2 = Join<["2", "2", "2"], 1>; // expected to be '21212' +type Res3 = Join<["o"], "u">; // expected to be 'o' ``` diff --git a/questions/5310-medium-join/info.yml b/questions/05310-medium-join/info.yml similarity index 100% rename from questions/5310-medium-join/info.yml rename to questions/05310-medium-join/info.yml diff --git a/questions/5310-medium-join/template.ts b/questions/05310-medium-join/template.ts similarity index 100% rename from questions/5310-medium-join/template.ts rename to questions/05310-medium-join/template.ts diff --git a/questions/5310-medium-join/test-cases.ts b/questions/05310-medium-join/test-cases.ts similarity index 97% rename from questions/5310-medium-join/test-cases.ts rename to questions/05310-medium-join/test-cases.ts index 705ceab2a..ec2317a8b 100644 --- a/questions/5310-medium-join/test-cases.ts +++ b/questions/05310-medium-join/test-cases.ts @@ -1,9 +1,9 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, 'a-p-p-l-e'>>, - Expect, 'Hello World'>>, - Expect, '21212'>>, - Expect, 'o'>>, -] +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, 'a-p-p-l-e'>>, + Expect, 'Hello World'>>, + Expect, '21212'>>, + Expect, 'o'>>, +] diff --git a/questions/5317-medium-lastindexof/README.md b/questions/05317-medium-lastindexof/README.md similarity index 99% rename from questions/5317-medium-lastindexof/README.md rename to questions/05317-medium-lastindexof/README.md index ff144588a..11e79d845 100644 --- a/questions/5317-medium-lastindexof/README.md +++ b/questions/05317-medium-lastindexof/README.md @@ -1,12 +1,12 @@

LastIndexOf medium #array

by jiangshan @jiangshanmeta

Take the Challenge

-Implement the type version of ```Array.lastIndexOf```, ```LastIndexOf``` takes an Array ```T```, any ```U``` and returns the index of the last ```U``` in Array ```T``` - -For example: - -```typescript -type Res1 = LastIndexOf<[1, 2, 3, 2, 1], 2> // 3 -type Res2 = LastIndexOf<[0, 0, 0], 2> // -1 +Implement the type version of ```Array.lastIndexOf```, ```LastIndexOf``` takes an Array ```T```, any ```U``` and returns the index of the last ```U``` in Array ```T``` + +For example: + +```typescript +type Res1 = LastIndexOf<[1, 2, 3, 2, 1], 2> // 3 +type Res2 = LastIndexOf<[0, 0, 0], 2> // -1 ``` diff --git a/questions/5317-medium-lastindexof/info.yml b/questions/05317-medium-lastindexof/info.yml similarity index 100% rename from questions/5317-medium-lastindexof/info.yml rename to questions/05317-medium-lastindexof/info.yml diff --git a/questions/5317-medium-lastindexof/template.ts b/questions/05317-medium-lastindexof/template.ts similarity index 100% rename from questions/5317-medium-lastindexof/template.ts rename to questions/05317-medium-lastindexof/template.ts diff --git a/questions/5317-medium-lastindexof/test-cases.ts b/questions/05317-medium-lastindexof/test-cases.ts similarity index 98% rename from questions/5317-medium-lastindexof/test-cases.ts rename to questions/05317-medium-lastindexof/test-cases.ts index db841d4c6..2bcfe4ed0 100644 --- a/questions/5317-medium-lastindexof/test-cases.ts +++ b/questions/05317-medium-lastindexof/test-cases.ts @@ -1,8 +1,8 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect, 3>>, - Expect, 7>>, - Expect, -1>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, 3>>, + Expect, 7>>, + Expect, -1>>, ] diff --git a/questions/5360-medium-unique/README.md b/questions/05360-medium-unique/README.md similarity index 99% rename from questions/5360-medium-unique/README.md rename to questions/05360-medium-unique/README.md index f2a3bcea6..5a0409b4a 100644 --- a/questions/5360-medium-unique/README.md +++ b/questions/05360-medium-unique/README.md @@ -1,14 +1,14 @@ -

Unique medium #array

by Pineapple @Pineapple0919

Take the Challenge

- -Implement the type version of Lodash.uniq, Unique takes an Array T, returns the Array T without repeated values. - -```ts -type Res = Unique<[1, 1, 2, 2, 3, 3]>; // expected to be [1, 2, 3] -type Res1 = Unique<[1, 2, 3, 4, 4, 5, 6, 7]>; // expected to be [1, 2, 3, 4, 5, 6, 7] -type Res2 = Unique<[1, "a", 2, "b", 2, "a"]>; // expected to be [1, "a", 2, "b"] -type Res3 = Unique<[string, number, 1, "a", 1, string, 2, "b", 2, number]>; // expected to be [string, number, 1, "a", 2, "b"] -type Res4 = Unique<[unknown, unknown, any, any, never, never]>; // expected to be [unknown, any, never] -``` - - +

Unique medium #array

by Pineapple @Pineapple0919

Take the Challenge

+ +Implement the type version of Lodash.uniq, Unique takes an Array T, returns the Array T without repeated values. + +```ts +type Res = Unique<[1, 1, 2, 2, 3, 3]>; // expected to be [1, 2, 3] +type Res1 = Unique<[1, 2, 3, 4, 4, 5, 6, 7]>; // expected to be [1, 2, 3, 4, 5, 6, 7] +type Res2 = Unique<[1, "a", 2, "b", 2, "a"]>; // expected to be [1, "a", 2, "b"] +type Res3 = Unique<[string, number, 1, "a", 1, string, 2, "b", 2, number]>; // expected to be [string, number, 1, "a", 2, "b"] +type Res4 = Unique<[unknown, unknown, any, any, never, never]>; // expected to be [unknown, any, never] +``` + +
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/5360-medium-unique/info.yml b/questions/05360-medium-unique/info.yml similarity index 100% rename from questions/5360-medium-unique/info.yml rename to questions/05360-medium-unique/info.yml diff --git a/questions/5360-medium-unique/template.ts b/questions/05360-medium-unique/template.ts similarity index 100% rename from questions/5360-medium-unique/template.ts rename to questions/05360-medium-unique/template.ts diff --git a/questions/5360-medium-unique/test-cases.ts b/questions/05360-medium-unique/test-cases.ts similarity index 98% rename from questions/5360-medium-unique/test-cases.ts rename to questions/05360-medium-unique/test-cases.ts index d817260dc..5d36809a1 100644 --- a/questions/5360-medium-unique/test-cases.ts +++ b/questions/05360-medium-unique/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, [1, 2, 3]>>, - Expect, [1, 2, 3, 4, 5, 6, 7]>>, - Expect, [1, 'a', 2, 'b']>>, - Expect, [string, number, 1, 'a', 2, 'b']>>, - Expect, [unknown, any, never]>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, [1, 2, 3]>>, + Expect, [1, 2, 3, 4, 5, 6, 7]>>, + Expect, [1, 'a', 2, 'b']>>, + Expect, [string, number, 1, 'a', 2, 'b']>>, + Expect, [unknown, any, never]>>, +] diff --git a/questions/5423-hard-intersection/README.md b/questions/05423-hard-intersection/README.md similarity index 99% rename from questions/5423-hard-intersection/README.md rename to questions/05423-hard-intersection/README.md index 5069fe895..b44cc4c31 100644 --- a/questions/5423-hard-intersection/README.md +++ b/questions/05423-hard-intersection/README.md @@ -1,14 +1,14 @@

Intersection hard #union #array

by Pineapple @Pineapple0919

Take the Challenge

-Implement the type version of Lodash.intersection, but there is a little different, Intersection takes an Array T containing several arrays or any type element that includes the union type, returns a new array containing all incoming array intersection elements. - -```ts -type Res = Intersection<[[1, 2], [2, 3], [2, 2]]>; // expected to be 2 -type Res1 = Intersection<[[1, 2, 3], [2, 3, 4], [2, 2, 3]]>; // expected to be 2 | 3 -type Res2 = Intersection<[[1, 2], [3, 4], [5, 6]]>; // expected to be never -type Res3 = Intersection<[[1, 2, 3], [2, 3, 4], 3]>; // expected to be 3 -type Res4 = Intersection<[[1, 2, 3], 2 | 3 | 4, 2 | 3]>; // expected to be 2 | 3 -type Res5 = Intersection<[[1, 2, 3], 2, 3]>; // expected to be never +Implement the type version of Lodash.intersection, but there is a little different, Intersection takes an Array T containing several arrays or any type element that includes the union type, returns a new array containing all incoming array intersection elements. + +```ts +type Res = Intersection<[[1, 2], [2, 3], [2, 2]]>; // expected to be 2 +type Res1 = Intersection<[[1, 2, 3], [2, 3, 4], [2, 2, 3]]>; // expected to be 2 | 3 +type Res2 = Intersection<[[1, 2], [3, 4], [5, 6]]>; // expected to be never +type Res3 = Intersection<[[1, 2, 3], [2, 3, 4], 3]>; // expected to be 3 +type Res4 = Intersection<[[1, 2, 3], 2 | 3 | 4, 2 | 3]>; // expected to be 2 | 3 +type Res5 = Intersection<[[1, 2, 3], 2, 3]>; // expected to be never ``` diff --git a/questions/5423-hard-intersection/info.yml b/questions/05423-hard-intersection/info.yml similarity index 100% rename from questions/5423-hard-intersection/info.yml rename to questions/05423-hard-intersection/info.yml diff --git a/questions/5423-hard-intersection/template.ts b/questions/05423-hard-intersection/template.ts similarity index 100% rename from questions/5423-hard-intersection/template.ts rename to questions/05423-hard-intersection/template.ts diff --git a/questions/5423-hard-intersection/test-cases.ts b/questions/05423-hard-intersection/test-cases.ts similarity index 98% rename from questions/5423-hard-intersection/test-cases.ts rename to questions/05423-hard-intersection/test-cases.ts index 7c828125c..d94b1c035 100644 --- a/questions/5423-hard-intersection/test-cases.ts +++ b/questions/05423-hard-intersection/test-cases.ts @@ -1,10 +1,10 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 2>>, - Expect, 2 | 3>>, - Expect, never>>, - Expect, 3>>, - Expect, 2 | 3>>, - Expect, never>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 2>>, + Expect, 2 | 3>>, + Expect, never>>, + Expect, 3>>, + Expect, 2 | 3>>, + Expect, never>>, ] diff --git a/questions/5821-medium-maptypes/README.md b/questions/05821-medium-maptypes/README.md similarity index 98% rename from questions/5821-medium-maptypes/README.md rename to questions/05821-medium-maptypes/README.md index 92604631d..d078fd3de 100644 --- a/questions/5821-medium-maptypes/README.md +++ b/questions/05821-medium-maptypes/README.md @@ -1,32 +1,32 @@

MapTypes medium #map #object #utils

by Krzysztof "Wokay" Łokaj @wokayme

Take the Challenge

-Implement `MapTypes` which will transform types in object T to different types defined by type R which has the following structure - -```ts -type StringToNumber = { - mapFrom: string; // value of key which value is string - mapTo: number; // will be transformed for number -} -``` - -## Examples: - -```ts -type StringToNumber = { mapFrom: string; mapTo: number;} -MapTypes<{iWillBeANumberOneDay: string}, StringToNumber> // gives { iWillBeANumberOneDay: number; } -``` - -Be aware that user can provide a union of types: -```ts -type StringToNumber = { mapFrom: string; mapTo: number;} -type StringToDate = { mapFrom: string; mapTo: Date;} -MapTypes<{iWillBeNumberOrDate: string}, StringToDate | StringToNumber> // gives { iWillBeNumberOrDate: number | Date; } -``` - -If the type doesn't exist in our map, leave it as it was: -```ts -type StringToNumber = { mapFrom: string; mapTo: number;} -MapTypes<{iWillBeANumberOneDay: string, iWillStayTheSame: Function}, StringToNumber> // // gives { iWillBeANumberOneDay: number, iWillStayTheSame: Function } +Implement `MapTypes` which will transform types in object T to different types defined by type R which has the following structure + +```ts +type StringToNumber = { + mapFrom: string; // value of key which value is string + mapTo: number; // will be transformed for number +} +``` + +## Examples: + +```ts +type StringToNumber = { mapFrom: string; mapTo: number;} +MapTypes<{iWillBeANumberOneDay: string}, StringToNumber> // gives { iWillBeANumberOneDay: number; } +``` + +Be aware that user can provide a union of types: +```ts +type StringToNumber = { mapFrom: string; mapTo: number;} +type StringToDate = { mapFrom: string; mapTo: Date;} +MapTypes<{iWillBeNumberOrDate: string}, StringToDate | StringToNumber> // gives { iWillBeNumberOrDate: number | Date; } +``` + +If the type doesn't exist in our map, leave it as it was: +```ts +type StringToNumber = { mapFrom: string; mapTo: number;} +MapTypes<{iWillBeANumberOneDay: string, iWillStayTheSame: Function}, StringToNumber> // // gives { iWillBeANumberOneDay: number, iWillStayTheSame: Function } ``` diff --git a/questions/5821-medium-maptypes/info.yml b/questions/05821-medium-maptypes/info.yml similarity index 100% rename from questions/5821-medium-maptypes/info.yml rename to questions/05821-medium-maptypes/info.yml diff --git a/questions/5821-medium-maptypes/template.ts b/questions/05821-medium-maptypes/template.ts similarity index 100% rename from questions/5821-medium-maptypes/template.ts rename to questions/05821-medium-maptypes/template.ts diff --git a/questions/5821-medium-maptypes/test-cases.ts b/questions/05821-medium-maptypes/test-cases.ts similarity index 99% rename from questions/5821-medium-maptypes/test-cases.ts rename to questions/05821-medium-maptypes/test-cases.ts index d595bcb97..dd21f52d0 100644 --- a/questions/5821-medium-maptypes/test-cases.ts +++ b/questions/05821-medium-maptypes/test-cases.ts @@ -1,12 +1,12 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, { stringToArray: [] }>>, - Expect, { stringToNumber: number }>>, - Expect, { stringToNumber: number; skipParsingMe: boolean }>>, - Expect, { date: null | Date }>>, - Expect, { date: null | Date }>>, - Expect }, { mapFrom: Record; mapTo: string[] }>, { fields: string[] }>>, - Expect, { name: string }>>, - Expect, { name: boolean; date: string }>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, { stringToArray: [] }>>, + Expect, { stringToNumber: number }>>, + Expect, { stringToNumber: number; skipParsingMe: boolean }>>, + Expect, { date: null | Date }>>, + Expect, { date: null | Date }>>, + Expect }, { mapFrom: Record; mapTo: string[] }>, { fields: string[] }>>, + Expect, { name: string }>>, + Expect, { name: boolean; date: string }>>, ] diff --git a/questions/6141-hard-binary-to-decimal/README.md b/questions/06141-hard-binary-to-decimal/README.md similarity index 99% rename from questions/6141-hard-binary-to-decimal/README.md rename to questions/06141-hard-binary-to-decimal/README.md index a9626c819..ac2db6c69 100644 --- a/questions/6141-hard-binary-to-decimal/README.md +++ b/questions/06141-hard-binary-to-decimal/README.md @@ -1,11 +1,11 @@

Binary to Decimal hard #math

by wotsushi @wotsushi

Take the Challenge

-Implement `BinaryToDecimal` which takes an exact string type `S` consisting 0 and 1 and returns an exact number type corresponding with `S` when `S` is regarded as a binary. -You can assume that the length of `S` is equal to or less than 8 and `S` is not empty. - -```ts -type Res1 = BinaryToDecimal<'10'>; // expected to be 2 -type Res2 = BinaryToDecimal<'0011'>; // expected to be 3 +Implement `BinaryToDecimal` which takes an exact string type `S` consisting 0 and 1 and returns an exact number type corresponding with `S` when `S` is regarded as a binary. +You can assume that the length of `S` is equal to or less than 8 and `S` is not empty. + +```ts +type Res1 = BinaryToDecimal<'10'>; // expected to be 2 +type Res2 = BinaryToDecimal<'0011'>; // expected to be 3 ``` diff --git a/questions/6141-hard-binary-to-decimal/info.yml b/questions/06141-hard-binary-to-decimal/info.yml similarity index 100% rename from questions/6141-hard-binary-to-decimal/info.yml rename to questions/06141-hard-binary-to-decimal/info.yml diff --git a/questions/6141-hard-binary-to-decimal/template.ts b/questions/06141-hard-binary-to-decimal/template.ts similarity index 100% rename from questions/6141-hard-binary-to-decimal/template.ts rename to questions/06141-hard-binary-to-decimal/template.ts diff --git a/questions/6141-hard-binary-to-decimal/test-cases.ts b/questions/06141-hard-binary-to-decimal/test-cases.ts similarity index 97% rename from questions/6141-hard-binary-to-decimal/test-cases.ts rename to questions/06141-hard-binary-to-decimal/test-cases.ts index 2c9544403..c749f82fb 100644 --- a/questions/6141-hard-binary-to-decimal/test-cases.ts +++ b/questions/06141-hard-binary-to-decimal/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 2>>, - Expect, 3>>, - Expect, 0>>, - Expect, 255>>, - Expect, 170>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 2>>, + Expect, 3>>, + Expect, 0>>, + Expect, 255>>, + Expect, 170>>, ] diff --git a/questions/6228-extreme-json-parser/README.md b/questions/06228-extreme-json-parser/README.md similarity index 99% rename from questions/6228-extreme-json-parser/README.md rename to questions/06228-extreme-json-parser/README.md index 129edadc7..e184a4db6 100644 --- a/questions/6228-extreme-json-parser/README.md +++ b/questions/06228-extreme-json-parser/README.md @@ -1,8 +1,8 @@

JSON Parser extreme #template-literal #json

by Hydrogen @hyroge

Take the Challenge

-You're required to implement a type-level partly parser to parse JSON string into a object literal type. - -Requirements: +You're required to implement a type-level partly parser to parse JSON string into a object literal type. + +Requirements: - `Numbers` and `Unicode escape (\uxxxx)` in JSON can be ignored. You needn't to parse them. diff --git a/questions/6228-extreme-json-parser/info.yml b/questions/06228-extreme-json-parser/info.yml similarity index 100% rename from questions/6228-extreme-json-parser/info.yml rename to questions/06228-extreme-json-parser/info.yml diff --git a/questions/6228-extreme-json-parser/template.ts b/questions/06228-extreme-json-parser/template.ts similarity index 97% rename from questions/6228-extreme-json-parser/template.ts rename to questions/06228-extreme-json-parser/template.ts index 6130529b0..a692a83c0 100644 --- a/questions/6228-extreme-json-parser/template.ts +++ b/questions/06228-extreme-json-parser/template.ts @@ -1,14 +1,14 @@ -type Pure = { - [P in keyof T]: T[P] extends object ? Pure : T[P] -} - -type SetProperty = { - [P in (keyof T) | K]: P extends K ? V : P extends keyof T ? T[P] : never -} - -type Token = any -type ParseResult = [T, K] -type Tokenize = Token[] -type ParseLiteral = ParseResult - +type Pure = { + [P in keyof T]: T[P] extends object ? Pure : T[P] +} + +type SetProperty = { + [P in (keyof T) | K]: P extends K ? V : P extends keyof T ? T[P] : never +} + +type Token = any +type ParseResult = [T, K] +type Tokenize = Token[] +type ParseLiteral = ParseResult + type Parse = Pure>[0]> diff --git a/questions/6228-extreme-json-parser/test-cases.ts b/questions/06228-extreme-json-parser/test-cases.ts similarity index 94% rename from questions/6228-extreme-json-parser/test-cases.ts rename to questions/06228-extreme-json-parser/test-cases.ts index f9a1416ab..22a70bcd5 100644 --- a/questions/6228-extreme-json-parser/test-cases.ts +++ b/questions/06228-extreme-json-parser/test-cases.ts @@ -1,60 +1,60 @@ import type { Equal, Expect } from '@type-challenges/utils' -import { ExpectFalse, NotEqual } from '@type-challenges/utils' - -type cases = [ - Expect - ), ( - { - nil: null - c: [true, false, 'hello', { - a: 'b' - b: false - }] - b: false - a: 'b' - } - - )>>, - Expect, {}>>, - - Expect, []>>, - - Expect, never>>, - - Expect, true>>, - - Expect, - ['Hello', true, false, null] - >>, - - Expect - ), ( - { - 'hello\r\n\b\f': 'world' - } - ) - >>, - - Expect, never>>, - - Expect, never>>, +import { ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect + ), ( + { + nil: null + c: [true, false, 'hello', { + a: 'b' + b: false + }] + b: false + a: 'b' + } + + )>>, + Expect, {}>>, + + Expect, []>>, + + Expect, never>>, + + Expect, true>>, + + Expect, + ['Hello', true, false, null] + >>, + + Expect + ), ( + { + 'hello\r\n\b\f': 'world' + } + ) + >>, + + Expect, never>>, + + Expect, never>>, ] diff --git a/questions/7258-hard-object-key-paths/README.md b/questions/07258-hard-object-key-paths/README.md similarity index 99% rename from questions/7258-hard-object-key-paths/README.md rename to questions/07258-hard-object-key-paths/README.md index 0b26ea3e1..1714cce56 100644 --- a/questions/7258-hard-object-key-paths/README.md +++ b/questions/07258-hard-object-key-paths/README.md @@ -1,14 +1,14 @@

Object Key Paths hard #object-keys

by CattChen @ChenKS12138

Take the Challenge

-Get all possible paths that could be called by [_.get](https://lodash.com/docs/4.17.15#get) (a lodash function) to get the value of an object - -```typescript -type T1 = ObjectKeyPaths<{ name: string; age: number }>; // expected to be 'name' | 'age' -type T2 = ObjectKeyPaths<{ - refCount: number; - person: { name: string; age: number }; -}>; // expected to be 'refCount' | 'person' | 'person.name' | 'person.age' -type T3 = ObjectKeyPaths<{ books: [{ name: string; price: number }] }>; // expected to be the superset of 'books' | 'books.0' | 'books[0]' | 'books.[0]' | 'books.0.name' | 'books.0.price' | 'books.length' | 'books.find' +Get all possible paths that could be called by [_.get](https://lodash.com/docs/4.17.15#get) (a lodash function) to get the value of an object + +```typescript +type T1 = ObjectKeyPaths<{ name: string; age: number }>; // expected to be 'name' | 'age' +type T2 = ObjectKeyPaths<{ + refCount: number; + person: { name: string; age: number }; +}>; // expected to be 'refCount' | 'person' | 'person.name' | 'person.age' +type T3 = ObjectKeyPaths<{ books: [{ name: string; price: number }] }>; // expected to be the superset of 'books' | 'books.0' | 'books[0]' | 'books.[0]' | 'books.0.name' | 'books.0.price' | 'books.length' | 'books.find' ``` diff --git a/questions/7258-hard-object-key-paths/info.yml b/questions/07258-hard-object-key-paths/info.yml similarity index 100% rename from questions/7258-hard-object-key-paths/info.yml rename to questions/07258-hard-object-key-paths/info.yml diff --git a/questions/7258-hard-object-key-paths/template.ts b/questions/07258-hard-object-key-paths/template.ts similarity index 100% rename from questions/7258-hard-object-key-paths/template.ts rename to questions/07258-hard-object-key-paths/template.ts diff --git a/questions/7258-medium-objectkeypaths/test-cases.ts b/questions/07258-hard-object-key-paths/test-cases.ts similarity index 97% rename from questions/7258-medium-objectkeypaths/test-cases.ts rename to questions/07258-hard-object-key-paths/test-cases.ts index cbd0f5c68..d95306d02 100644 --- a/questions/7258-medium-objectkeypaths/test-cases.ts +++ b/questions/07258-hard-object-key-paths/test-cases.ts @@ -1,40 +1,40 @@ -import type { Equal, Expect, ExpectExtends } from '@type-challenges/utils' - -const ref = { - count: 1, - person: { - name: 'cattchen', - age: 22, - books: ['book1', 'book2'], - pets: [ - { - type: 'cat', - }, - ], - }, -} - -type cases = [ - Expect, 'name' | 'age'>>, - Expect< - Equal< - ObjectKeyPaths<{ - refCount: number - person: { name: string; age: number } - }>, - 'refCount' | 'person' | 'person.name' | 'person.age' - > - >, - Expect, 'count'>>, - Expect, 'person'>>, - Expect, 'person.name'>>, - Expect, 'person.age'>>, - Expect, 'person.books'>>, - Expect, 'person.pets'>>, - Expect, 'person.books.0'>>, - Expect, 'person.books.1'>>, - Expect, 'person.books[0]'>>, - Expect, 'person.books.[0]'>>, - Expect, 'person.pets.0.type'>>, - Expect, 'notExist'>, false>>, -] +import type { Equal, Expect, ExpectExtends } from '@type-challenges/utils' + +const ref = { + count: 1, + person: { + name: 'cattchen', + age: 22, + books: ['book1', 'book2'], + pets: [ + { + type: 'cat', + }, + ], + }, +} + +type cases = [ + Expect, 'name' | 'age'>>, + Expect< + Equal< + ObjectKeyPaths<{ + refCount: number + person: { name: string; age: number } + }>, + 'refCount' | 'person' | 'person.name' | 'person.age' + > + >, + Expect, 'count'>>, + Expect, 'person'>>, + Expect, 'person.name'>>, + Expect, 'person.age'>>, + Expect, 'person.books'>>, + Expect, 'person.pets'>>, + Expect, 'person.books.0'>>, + Expect, 'person.books.1'>>, + Expect, 'person.books[0]'>>, + Expect, 'person.books.[0]'>>, + Expect, 'person.pets.0.type'>>, + Expect, 'notExist'>, false>>, +] diff --git a/questions/7258-medium-objectkeypaths/README.md b/questions/07258-medium-objectkeypaths/README.md similarity index 99% rename from questions/7258-medium-objectkeypaths/README.md rename to questions/07258-medium-objectkeypaths/README.md index f907a85a3..ddc391116 100644 --- a/questions/7258-medium-objectkeypaths/README.md +++ b/questions/07258-medium-objectkeypaths/README.md @@ -1,14 +1,14 @@

ObjectKeyPaths medium #object-keys

by CattChen @ChenKS12138

Take the Challenge

-Get all possible paths that could be called by [_.get](https://lodash.com/docs/4.17.15#get) (a lodash function) to get the value of an object - -```typescript -type T1 = ObjectKeyPaths<{ name: string; age: number }>; // expected to be 'name' | 'age' -type T2 = ObjectKeyPaths<{ - refCount: number; - person: { name: string; age: number }; -}>; // expected to be 'refCount' | 'person' | 'person.name' | 'person.age' -type T3 = ObjectKeyPaths<{ books: [{ name: string; price: number }] }>; // expected to be the superset of 'books' | 'books.0' | 'books[0]' | 'books.[0]' | 'books.0.name' | 'books.0.price' | 'books.length' | 'books.find' +Get all possible paths that could be called by [_.get](https://lodash.com/docs/4.17.15#get) (a lodash function) to get the value of an object + +```typescript +type T1 = ObjectKeyPaths<{ name: string; age: number }>; // expected to be 'name' | 'age' +type T2 = ObjectKeyPaths<{ + refCount: number; + person: { name: string; age: number }; +}>; // expected to be 'refCount' | 'person' | 'person.name' | 'person.age' +type T3 = ObjectKeyPaths<{ books: [{ name: string; price: number }] }>; // expected to be the superset of 'books' | 'books.0' | 'books[0]' | 'books.[0]' | 'books.0.name' | 'books.0.price' | 'books.length' | 'books.find' ``` diff --git a/questions/7258-medium-objectkeypaths/info.yml b/questions/07258-medium-objectkeypaths/info.yml similarity index 100% rename from questions/7258-medium-objectkeypaths/info.yml rename to questions/07258-medium-objectkeypaths/info.yml diff --git a/questions/7258-medium-objectkeypaths/template.ts b/questions/07258-medium-objectkeypaths/template.ts similarity index 100% rename from questions/7258-medium-objectkeypaths/template.ts rename to questions/07258-medium-objectkeypaths/template.ts diff --git a/questions/7258-hard-object-key-paths/test-cases.ts b/questions/07258-medium-objectkeypaths/test-cases.ts similarity index 97% rename from questions/7258-hard-object-key-paths/test-cases.ts rename to questions/07258-medium-objectkeypaths/test-cases.ts index cbd0f5c68..d95306d02 100644 --- a/questions/7258-hard-object-key-paths/test-cases.ts +++ b/questions/07258-medium-objectkeypaths/test-cases.ts @@ -1,40 +1,40 @@ -import type { Equal, Expect, ExpectExtends } from '@type-challenges/utils' - -const ref = { - count: 1, - person: { - name: 'cattchen', - age: 22, - books: ['book1', 'book2'], - pets: [ - { - type: 'cat', - }, - ], - }, -} - -type cases = [ - Expect, 'name' | 'age'>>, - Expect< - Equal< - ObjectKeyPaths<{ - refCount: number - person: { name: string; age: number } - }>, - 'refCount' | 'person' | 'person.name' | 'person.age' - > - >, - Expect, 'count'>>, - Expect, 'person'>>, - Expect, 'person.name'>>, - Expect, 'person.age'>>, - Expect, 'person.books'>>, - Expect, 'person.pets'>>, - Expect, 'person.books.0'>>, - Expect, 'person.books.1'>>, - Expect, 'person.books[0]'>>, - Expect, 'person.books.[0]'>>, - Expect, 'person.pets.0.type'>>, - Expect, 'notExist'>, false>>, -] +import type { Equal, Expect, ExpectExtends } from '@type-challenges/utils' + +const ref = { + count: 1, + person: { + name: 'cattchen', + age: 22, + books: ['book1', 'book2'], + pets: [ + { + type: 'cat', + }, + ], + }, +} + +type cases = [ + Expect, 'name' | 'age'>>, + Expect< + Equal< + ObjectKeyPaths<{ + refCount: number + person: { name: string; age: number } + }>, + 'refCount' | 'person' | 'person.name' | 'person.age' + > + >, + Expect, 'count'>>, + Expect, 'person'>>, + Expect, 'person.name'>>, + Expect, 'person.age'>>, + Expect, 'person.books'>>, + Expect, 'person.pets'>>, + Expect, 'person.books.0'>>, + Expect, 'person.books.1'>>, + Expect, 'person.books[0]'>>, + Expect, 'person.books.[0]'>>, + Expect, 'person.pets.0.type'>>, + Expect, 'notExist'>, false>>, +] diff --git a/questions/7544-medium-construct-tuple/README.md b/questions/07544-medium-construct-tuple/README.md similarity index 99% rename from questions/7544-medium-construct-tuple/README.md rename to questions/07544-medium-construct-tuple/README.md index a9545b06a..bc65c8a2b 100644 --- a/questions/7544-medium-construct-tuple/README.md +++ b/questions/07544-medium-construct-tuple/README.md @@ -1,11 +1,11 @@

Construct Tuple medium #tuple

by Lo @LoTwT

Take the Challenge

-Construct a tuple with a given length. - -For example - -```ts -type result = ConstructTuple<2> // expect to be [unknown, unkonwn] +Construct a tuple with a given length. + +For example + +```ts +type result = ConstructTuple<2> // expect to be [unknown, unkonwn] ``` diff --git a/questions/7544-medium-construct-tuple/info.yml b/questions/07544-medium-construct-tuple/info.yml similarity index 100% rename from questions/7544-medium-construct-tuple/info.yml rename to questions/07544-medium-construct-tuple/info.yml diff --git a/questions/7544-medium-construct-tuple/template.ts b/questions/07544-medium-construct-tuple/template.ts similarity index 100% rename from questions/7544-medium-construct-tuple/template.ts rename to questions/07544-medium-construct-tuple/template.ts diff --git a/questions/7544-medium-construct-tuple/test-cases.ts b/questions/07544-medium-construct-tuple/test-cases.ts similarity index 97% rename from questions/7544-medium-construct-tuple/test-cases.ts rename to questions/07544-medium-construct-tuple/test-cases.ts index 3df5b7027..cf6bb6915 100644 --- a/questions/7544-medium-construct-tuple/test-cases.ts +++ b/questions/07544-medium-construct-tuple/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, []>>, - Expect, [unknown, unknown]>>, - Expect['length'], 999>>, - // @ts-expect-error - Expect['length'], 1000>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, []>>, + Expect, [unknown, unknown]>>, + Expect['length'], 999>>, + // @ts-expect-error + Expect['length'], 1000>>, ] diff --git a/questions/7561-extreme-subtract/README.md b/questions/07561-extreme-subtract/README.md similarity index 99% rename from questions/7561-extreme-subtract/README.md rename to questions/07561-extreme-subtract/README.md index 96d5ec31f..76210e381 100644 --- a/questions/7561-extreme-subtract/README.md +++ b/questions/07561-extreme-subtract/README.md @@ -1,16 +1,16 @@

Subtract extreme #tuple

by Lo @LoTwT

Take the Challenge

-Implement the type Subtraction that is ` - ` in Javascript by using BuildTuple. - -If the minuend is less than the subtrahend, it should be `never`. - -It's a simple version. - -For example - -```ts -Subtract<2, 1> // expect to be 1 -Subtract<1, 2> // expect to be never +Implement the type Subtraction that is ` - ` in Javascript by using BuildTuple. + +If the minuend is less than the subtrahend, it should be `never`. + +It's a simple version. + +For example + +```ts +Subtract<2, 1> // expect to be 1 +Subtract<1, 2> // expect to be never ``` diff --git a/questions/7561-extreme-subtract/info.yml b/questions/07561-extreme-subtract/info.yml similarity index 100% rename from questions/7561-extreme-subtract/info.yml rename to questions/07561-extreme-subtract/info.yml diff --git a/questions/7561-extreme-subtract/template.ts b/questions/07561-extreme-subtract/template.ts similarity index 98% rename from questions/7561-extreme-subtract/template.ts rename to questions/07561-extreme-subtract/template.ts index deb810e75..b26cc6c8b 100644 --- a/questions/7561-extreme-subtract/template.ts +++ b/questions/07561-extreme-subtract/template.ts @@ -1,2 +1,2 @@ -// M => minuend, S => subtrahend +// M => minuend, S => subtrahend type Subtract = any diff --git a/questions/7561-extreme-subtract/test-cases.ts b/questions/07561-extreme-subtract/test-cases.ts similarity index 96% rename from questions/7561-extreme-subtract/test-cases.ts rename to questions/07561-extreme-subtract/test-cases.ts index ce3e75d40..cf993e590 100644 --- a/questions/7561-extreme-subtract/test-cases.ts +++ b/questions/07561-extreme-subtract/test-cases.ts @@ -1,9 +1,9 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, 0>>, - Expect, 1>>, - Expect, never>>, - // @ts-expect-error - Expect, 1>>, +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, 0>>, + Expect, 1>>, + Expect, never>>, + // @ts-expect-error + Expect, 1>>, ] diff --git a/questions/8640-medium-number-range/README.md b/questions/08640-medium-number-range/README.md similarity index 99% rename from questions/8640-medium-number-range/README.md rename to questions/08640-medium-number-range/README.md index d2e26feeb..4a39cff0a 100644 --- a/questions/8640-medium-number-range/README.md +++ b/questions/08640-medium-number-range/README.md @@ -1,9 +1,9 @@

Number Range medium

by AaronGuo @HongxuanG

Take the Challenge

-Sometimes we want to limit the range of numbers... -For examples. -``` -type result = NumberRange<2 , 9> // | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 +Sometimes we want to limit the range of numbers... +For examples. +``` +type result = NumberRange<2 , 9> // | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ``` diff --git a/questions/8640-medium-number-range/info.yml b/questions/08640-medium-number-range/info.yml similarity index 100% rename from questions/8640-medium-number-range/info.yml rename to questions/08640-medium-number-range/info.yml diff --git a/questions/8640-medium-number-range/template.ts b/questions/08640-medium-number-range/template.ts similarity index 100% rename from questions/8640-medium-number-range/template.ts rename to questions/08640-medium-number-range/template.ts diff --git a/questions/8640-medium-number-range/test-cases.ts b/questions/08640-medium-number-range/test-cases.ts similarity index 97% rename from questions/8640-medium-number-range/test-cases.ts rename to questions/08640-medium-number-range/test-cases.ts index fa50b0f7b..67d420cc0 100644 --- a/questions/8640-medium-number-range/test-cases.ts +++ b/questions/08640-medium-number-range/test-cases.ts @@ -1,23 +1,23 @@ -import type { Equal, Expect } from '@type-challenges/utils' -type Result1 = | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 -type Result2 = | 0 | 1 | 2 -type Result3 = - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 - | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 - | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 - | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 - | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 - | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 - | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 - | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 - | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 - | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 - | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 - | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 - | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 -type cases = [ - Expect, Result1>>, - Expect, Result2>>, - Expect, Result3>>, +import type { Equal, Expect } from '@type-challenges/utils' +type Result1 = | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 +type Result2 = | 0 | 1 | 2 +type Result3 = + | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 + | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 + | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 + | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 + | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 + | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 + | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 + | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 + | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 + | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 + | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 + | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 + | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 + | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 +type cases = [ + Expect, Result1>>, + Expect, Result2>>, + Expect, Result3>>, ] diff --git a/questions/8767-medium-combination/README.md b/questions/08767-medium-combination/README.md similarity index 99% rename from questions/8767-medium-combination/README.md rename to questions/08767-medium-combination/README.md index 4c4e6236a..945f87c30 100644 --- a/questions/8767-medium-combination/README.md +++ b/questions/08767-medium-combination/README.md @@ -1,12 +1,12 @@ -

Combination medium #array #application #string

by Homyee King @HomyeeKing

Take the Challenge

- -Given an array of strings, do Permutation & Combination. -It's also useful for the prop types like video [controlsList](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/controlsList) - -```ts -// expected to be `"foo" | "bar" | "baz" | "foo bar baz" | "bar foo" | "baz foo" | "baz bar"` -type Keys = Combination<['foo', 'bar', 'baz']> -``` - - +

Combination medium #array #application #string

by Homyee King @HomyeeKing

Take the Challenge

+ +Given an array of strings, do Permutation & Combination. +It's also useful for the prop types like video [controlsList](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/controlsList) + +```ts +// expected to be `"foo" | "bar" | "baz" | "foo bar baz" | "bar foo" | "baz foo" | "baz bar"` +type Keys = Combination<['foo', 'bar', 'baz']> +``` + +
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/8767-medium-combination/info.yml b/questions/08767-medium-combination/info.yml similarity index 100% rename from questions/8767-medium-combination/info.yml rename to questions/08767-medium-combination/info.yml diff --git a/questions/8767-medium-combination/template.ts b/questions/08767-medium-combination/template.ts similarity index 100% rename from questions/8767-medium-combination/template.ts rename to questions/08767-medium-combination/template.ts diff --git a/questions/8767-medium-combination/test-cases.ts b/questions/08767-medium-combination/test-cases.ts similarity index 97% rename from questions/8767-medium-combination/test-cases.ts rename to questions/08767-medium-combination/test-cases.ts index a15905d5a..d4547ef9c 100644 --- a/questions/8767-medium-combination/test-cases.ts +++ b/questions/08767-medium-combination/test-cases.ts @@ -1,6 +1,6 @@ -import type { Equal, Expect } from '@type-challenges/utils' - -type cases = [ - Expect, - 'foo' | 'bar' | 'baz' | 'foo bar baz' | 'bar foo' | 'baz foo' | 'baz bar'>>, -] +import type { Equal, Expect } from '@type-challenges/utils' + +type cases = [ + Expect, + 'foo' | 'bar' | 'baz' | 'foo bar baz' | 'bar foo' | 'baz foo' | 'baz bar'>>, +] diff --git a/scripts/actions/issue-pr.ts b/scripts/actions/issue-pr.ts index 405e569c6..9e6bdd0f0 100644 --- a/scripts/actions/issue-pr.ts +++ b/scripts/actions/issue-pr.ts @@ -85,7 +85,7 @@ const action: Action = async(github, context, core) => { return } - const { data: user } = await github.users.getByUsername({ + const { data: user } = await github.rest.users.getByUsername({ username: issue.user.login, }) @@ -117,18 +117,17 @@ const action: Action = async(github, context, core) => { core.info('-----Parsed-----') core.info(JSON.stringify(quiz, null, 2)) - const { data: pulls } = await github.pulls.list({ + const { data: pulls } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, state: 'open', }) const existing_pull = pulls.find( - i => - i.user.login === 'github-actions[bot]' && i.title.startsWith(`#${no} `), + i => i.user?.login === 'github-actions[bot]' && i.title.startsWith(`#${no} `), ) - const dir = `questions/${no}-${info.difficulty}-${slug( + const dir = `questions/${String(no).padStart(5, '0')}-${info.difficulty}-${slug( info.title.replace(/\./g, '-').replace(/<.*>/g, ''), { tone: false }, )}` @@ -150,7 +149,7 @@ const action: Action = async(github, context, core) => { files, commit: `feat(question): add #${no} - ${info.title}`, author: { - name: user.name || user.login, + name: (user.name || user.id || user.login) as string, email: userEmail, }, }, @@ -183,7 +182,7 @@ const action: Action = async(github, context, core) => { } else { core.info('-----Creating PR-----') - const { data: pr } = await github.pulls.create({ + const { data: pr } = await github.rest.pulls.create({ owner: context.repo.owner, repo: context.repo.repo, base: 'master', @@ -193,7 +192,7 @@ const action: Action = async(github, context, core) => { labels: ['auto-generated'], }) - await github.issues.addLabels({ + await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: pr.number, @@ -213,18 +212,18 @@ const action: Action = async(github, context, core) => { } async function updateComment(github: Github, context: Context, body: string) { - const { data: comments } = await github.issues.listComments({ + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, }) const existing_comment = comments.find( - i => i.user.login === 'github-actions[bot]', + i => i.user?.login === 'github-actions[bot]', ) if (existing_comment) { - return await github.issues.updateComment({ + return await github.rest.issues.updateComment({ comment_id: existing_comment.id, issue_number: context.issue.number, owner: context.repo.owner, @@ -233,7 +232,7 @@ async function updateComment(github: Github, context: Context, body: string) { }) } else { - return await github.issues.createComment({ + return await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo,