Skip to content

Conversation

@okuramasafumi
Copy link

https://github.com/basarat/typescript-book/blob/master/docs/types/typeGuard.md

TypeScript doesn't assume type guards remain active in callbacks as making this assumption is dangerous. e.g.

ここでは"this assumption is dangerous"なので、危険なのはタイプガードではなくて仮定のほうだと思います。

The fix is as easy as storing the inferred safe value in a local variable, automatically ensuring it doesn't get changed externally, and TypeScript can easily understand that:

"ensuring"の単語が訳出されておらず、また"easy"なのは最初のカンマまでなので、それを踏まえて訳を変更しました。

Copy link
Collaborator

@yottahmd yottahmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正いただき、ありがとうございます!

@yottahmd yottahmd merged commit 54d2b3c into typescript-book-ja:master Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants