[230811] Typescript is
‘is’ 키워드
function isString(test: unknown): test is string{
return typeof test === "string";
}
function example(foo: unknown){
if(isString(foo)){
}
}
example("hello world");
- 이렇게 하면 test 인자가 무조건
string
이라고 인식함
Leave a comment