Created
April 25, 2021 14:07
-
-
Save gatherKnowledge/0cf565f19b547ed9f0dc7c4ed34c2b10 to your computer and use it in GitHub Desktop.
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
type MyType = { | |
a1: number; | |
a2: number; | |
a3: string; | |
} | |
const foo1 = { | |
a1: 1 | |
}; | |
const foo2 = foo1 as MyType; | |
console.log(foo2); // a1만 존재한다 => as는 type을 속이기 위한 방법일 뿐이다. | |
const foo3: any = { | |
a1: '1' | |
}; | |
const foo4 = foo3 as MyType; | |
console.log(foo4); | |
const foo5: any = { | |
a1: 1, | |
b1: 1 | |
}; | |
const foo6 = foo5 as MyType; | |
console.log(foo6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment