Skip to content

Commit c3fa038

Browse files
feat: New subPartial exercise
1 parent 4eff058 commit c3fa038

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

src/pages/Exercises.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@ export function Exercises() {
66
const exercises = data?.exercises ?? [];
77
return (
88
<>
9-
Welcome to TypeScript exercises!
9+
<h2 className="text-3xl m-24">Welcome to TypeScript exercises!</h2>
1010
<br />
1111
{loading ? (
1212
'Loading exercises...'
1313
) : (
1414
<>
15-
Available exercises:
16-
<ul>
15+
<div className="m-4 flex justify-around w-full max-w-196">
1716
{exercises.map(exercise => (
18-
<li key={exercise}>
19-
<a href={`/exercise/${exercise}`}>
20-
<Button value={exercise} size="sm" className="cursor-pointer">
21-
{exercise}
22-
</Button>
23-
</a>
24-
</li>
17+
<a href={`/exercise/${exercise}`} key={exercise}>
18+
<Button value={exercise} className="cursor-pointer h-16 w-42 flex items-center justify-center text-lg uppercase">
19+
{exercise}
20+
</Button>
21+
</a>
2522
))}
26-
</ul>
23+
</div>
2724
</>
2825
)}
2926
</>

templates/subPartial.template.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { Expect } from '@type-challenges/utils';
2+
3+
// fixed implementation
4+
type Equal<X, Y> =
5+
(<T>() => T extends Omit<X, never> ? 1 : 2) extends <T>() => T extends Omit<Y, never> ? 1 : 2 ? true : false;
6+
7+
type PartialByKeys</* SHORT_INPUT */> = /* LONG_INPUT */;
8+
9+
/* Test Cases */
10+
11+
interface User {
12+
name: string;
13+
age: number;
14+
address: string;
15+
}
16+
17+
type Cases = [
18+
Expect<Equal<PartialByKeys<User, "name">, UserPartialName>>,
19+
Expect<Equal<PartialByKeys<User, "name" | "age">, UserPartialNameAndAge>>,
20+
Expect<Equal<PartialByKeys<User>, Partial<User>>>,
21+
// @ts-expect-error
22+
Expect<Equal<PartialByKeys<User, "name" | "unknown">, UserPartialName>>,
23+
];
24+
25+
interface UserPartialName {
26+
name?: string;
27+
age: number;
28+
address: string;
29+
}
30+
31+
interface UserPartialNameAndAge {
32+
name?: string;
33+
age?: number;
34+
address: string;
35+
}

0 commit comments

Comments
 (0)