forked from type-challenges/type-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: cutefcc <63641648+cutefcc@users.noreply.github.com>
- Loading branch information
1 parent
7fd8982
commit e5816c3
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Returns true if all elements of the list are equal to the second parameter passed in, false if there are any mismatches. | ||
|
||
For example | ||
|
||
```ts | ||
type Test1 = [1, 1, 1] | ||
type Test2 = [1, 1, 2] | ||
|
||
type Todo = All<Test1, 1> // should be same as true | ||
type Todo2 = All<Test2, 1> // should be same as false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
difficulty: medium | ||
title: All | ||
author: | ||
github: cutefcc | ||
name: cutefcc | ||
tags: array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type All = any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Equal, Expect } from '@type-challenges/utils' | ||
|
||
type cases = [ | ||
Expect<Equal<All<[1, 1, 1], 1>, true>>, | ||
Expect<Equal<All<[1, 1, 2], 1>, false>>, | ||
Expect<Equal<All<["1", "1", "1"], "1">, true>>, | ||
Expect<Equal<All<["1", "1", "1"], 1>, false>>, | ||
Expect<Equal<All<[number, number, number], number>, true>>, | ||
Expect<Equal<All<[number, number, string], number>, false>>, | ||
Expect<Equal<All<[null, null, null], null>, true>>, | ||
Expect<Equal<All<[[1], [1], [1]], [1]>, true>>, | ||
Expect<Equal<All<[{}, {}, {}], {}>, true>>, | ||
]; |