-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed as not planned
Closed as not planned
Copy link
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
๐ Search Terms
type guard parameter any unknown
๐ Version & Regression Information
- This changed between versions 4.9.6 and 5.0.4
โฏ Playground Link
๐ป Code
interface Box<T> {
value: T
}
function isBox<T>(box: unknown): box is Box<T> {
return true
}
const numberBox: Box<unknown> = {value:1}
if (isBox<number>(numberBox)) {
numberBox.value
// ^?
}
if (isBox<any>(numberBox)) {
numberBox.value
// ^?
}๐ Actual behavior
if (isBox<any>(numberBox)) {
numberBox.value
// ^? (property) Box<unknown>.value: unknown
}๐ Expected behavior
if (isBox<any>(numberBox)) {
numberBox.value
// ^? (property) Box<any>.value: any
}Additional information about the issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options