Skip to content

Commit f27b2f9

Browse files
committed
๐Ÿšฉ: ์œ ๋‹ˆ์–ธ ํƒ€์ž…๊ณผ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด type
1 parent 57fd84f commit f27b2f9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

โ€Žsrc/data/data.tsโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export let user: userType = {
2323
name: 'dongwoo',
2424
age: 30,
2525
birthYear: 2000,
26-
26+
// ์˜ค๋กœ์ง€ score์—์„œ ์ •ํ•ด์ง„ ์ •์˜๋งŒ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
2727
1: 'A',
2828
2: 'B',
2929
3: 'A',
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
//grade๋ฅผ ๋ฌธ์ž์—ด๋กœ ์„ ์–ธํ•˜๊ธฐ์—๋Š” ๋„ˆ๋ฌด ๊ด‘๋ฒ”์œ„ํ•˜๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋ฅผ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด ๋ฐฉ์‹์œผ๋กœ ํƒ€์ž…์„ ํ•˜๋‚˜ ์„ ์–ธ ํ•ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
2+
3+
type Score = 'A' | 'B' | 'C' | 'F';
4+
//type์€ ์ •ํ™•ํžˆ ์–ด๋–ค ๊ฒƒ์ธ๊ฐ€?
5+
16
export interface userType {
27
name: string,
38
age: number,
49
// ๋’ค์— "?"๊ฐ€ ์žˆ๋Š” ๊ฒƒ์€ ์˜ต์…”๋„๋กœ gender๋ฅผ ์ž…๋ ฅ์„ ํ•ด๋„ ๋˜๊ณ  ์•ˆํ•ด๋„ ๋˜๋Š” ๋ฐฉ์‹์ด๋‹ค.
510
gender?: string,
611
readonly birthYear: number,
712
//key value ๋ฐฉ์‹์˜ ์ธ๋ฑ์Šค ์‹œ๊ทธ๋‹ˆ์ฒ˜ (ํ”„๋กœํผํ‹ฐ) ์„ ์–ธ
8-
[grade: number]: string;
13+
[grade: number]: Score;
914
}
10-
11-
//grade๋ฅผ ๋ฌธ์ž์—ด๋กœ ์„ ์–ธํ•˜๊ธฐ์—๋Š” ๋„ˆ๋ฌด ๊ด‘๋ฒ”์œ„ํ•˜๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋ฅผ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด ๋ฐฉ์‹์œผ๋กœ ํƒ€์ž…์„ ํ•˜๋‚˜ ์„ ์–ธ ํ•ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
12-
13-
type Score = 'A' | 'B' | 'C' | 'F';
14-
//type์€ ์ •ํ™•ํžˆ ์–ด๋–ค ๊ฒƒ์ธ๊ฐ€?

0 commit comments

Comments
ย (0)