Skip to content

Purpose and safety of Any/Compute #177

Answered by millsp
michalczaplinski asked this question in Wiki
Discussion options

You must be logged in to vote

I assume that this is purely for efficiency yes, or so that we can abstract certain types away (that we don't want to show), or both at the same time.

It is completely safe, there is absolutely no type loss. However, there is a drawback at the moment:

type O = {
    a: 'a'
    o: O
} & {
    b: {
        o: O
    }
}

type ComputedO = Compute<O>

Will yield a type that, when you look at it, is filled with anys. It just looks like any. In fact the type information is well preserved:

type test0 = ComputedO['o']['o']['o']['a']

This happens only on circular references. Lucky for us, I'm going to roll out a version that is able to handle circular references - to have even more beautiful outputs…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by millsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Wiki
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #156 on February 02, 2021 21:27.