-
Notifications
You must be signed in to change notification settings - Fork 0
Udemy/Ts/section2/29 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or 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
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 작성한 커밋입니다.
Github에서 작성한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✍Udemy/Ts/section2/29
🔥KeyWord
📝Description
userInput
이unknown
타입으로 할당되어 있는 상황에서string
타입이 할당된userName
에userName = userInput;
으로 재할당하게 되면error ts(2322)
를 반환한다. 이유는 다음과 같다.userInput
의 마지막 할당 타입은 string이다. 같은 타입을 가진 두 변수가 왜 할당할 수 없을까?userInput
은unknown
으로 타입이 할당되어 있는 것을 알 수있다. 이는any
와 달리 타입의 안정성을 확보하기 위함이다. 따라 타입을 좁혀나가는 방식이 무조건 적으로 필요하다는 것이다. 따라 if문과 같이 조건문에typeof
를 사용해서 타입을 좁혀나가야만unknown
타입을 명확히 사용할 수 있다. 결론적으로unknown
은any
와 다르게unknown
의 타입을 강건하게 고수는 타입이라는 것을 알 수 있다.📌Summary