Skip to content

Test generic type and see if its wrapped in a ref? #10467

Discussion options

You must be logged in to vote

What do you want to do when "checking" this? can you give an example? In general, these things are usually done with an extends check in a conditional type, i.e.

type X =  T extends Ref ? SomeType : SomeOtherType
//with inference of the nested type:
type X =  T extends Ref<infer U> ? SomeType<U> : SomeOtherType<U>

// extract the nested type:
type NestedT = T extends Ref<infer U> ? U : T
// Vue has a helper for that:
type NestedT = UnwrapRef<T>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Ncage1974
Comment options

Answer selected by Ncage1974
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants