#How to check if union type can be undefined or not using extends?
7 messages · Page 1 of 1 (latest)
Preview:```ts
type MyType = string | undefined
type IsUndefined = MyType extends undefined
? "yes"
: "no"
// ^?```
You can choose specific lines to embed by selecting them before copying the link.
@undone apex MyType extends undefined checks if your type is a subtype of undefined - you'd want the reverse: undefined extends MyType ? 'yes' : 'no'
This checks if undefined is a subtype of your type.
!resolved