Skip to content

Instantly share code, notes, and snippets.

@gatherKnowledge
Created April 25, 2021 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatherKnowledge/0cf565f19b547ed9f0dc7c4ed34c2b10 to your computer and use it in GitHub Desktop.
Save gatherKnowledge/0cf565f19b547ed9f0dc7c4ed34c2b10 to your computer and use it in GitHub Desktop.
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