-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopic3.tsx
31 lines (23 loc) · 815 Bytes
/
topic3.tsx
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
import type { NextPage } from "next";
import styles from "../styles/Home.module.css";
const Topic3: NextPage = () => {
type IamString<T> = T extends string ? "I am string" : "I am not string";
type str = IamString<string>; // "I am string"
type notStr = IamString<number>; // "I am not string"
// ///////////////////////////////
type FavoriteColors =
| "dark sienna"
| "sap green"
| "baby blue"
| [number, number, number]
| { red: number; green: number; blue: number };
type StringColors = Extract<FavoriteColors, string>;
type ObjectColors = Extract<FavoriteColors, { red: number }>;
type NonString = Exclude<FavoriteColors, string>;
return (
<div className={styles.container}>
<main className={styles.main}></main>
</div>
);
};
export default Topic3;