Skip to content

Commit f85596c

Browse files
committed
🚩: Alias Type을 ν™œμš©ν•œ Union Type μ§€μ • 방식과 ν™œμš© μ˜ˆμ‹œ
1 parent 03086af commit f85596c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

β€Žsrc/app.tsβ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//항상 μœ λ‹ˆμ˜¨ νƒ€μž…μ„ μ§€μ •ν•˜λŠ” 것은 많이 λ²ˆκ±°λ‘­λ‹€. 이에 alias νƒ€μž…μœΌλ‘œ μ‚¬μš©μž μ§€μ • νƒ€μž…μ„ μ •ν•  수 μžˆλ‹€. 즉, νƒ€μž…μ„ μš°λ¦¬κ°€ λ‹€λ‘œ λ³„μΉ­μœΌλ‘œ λ§Œλ“€μ–΄ λ‚Ό 수 μžˆλ‹€.
22

3-
type Combinable = number;
3+
type Combinable = number | string;
4+
type ConversionCustom = 'as-number' | 'as-text';
45

56
function combine(
6-
n1: Combinable | string,
7-
n2: Combinable | string,
8-
resultConversion: 'as-number' | 'as-text',
7+
n1: Combinable,
8+
n2: Combinable,
9+
resultConversion: ConversionCustom,
910
) {
1011
let result;
1112
if (typeof n1 === 'number' && typeof n2 === 'number' || resultConversion === 'as-number') {

0 commit comments

Comments
Β (0)