Skip to content

Self referencing type with maximum depth #227

Answered by nandorojo
nandorojo asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure if this is allowed, but looks like ignoring depth made it work:

type Item = {
    name: string
    dropdownItems?: Item[]
}

const item: Item = {
    name: 'Settings',
    dropdownItems: [{
        name: 'Notifications'
    }]
}

@millsp should I be concerned about infinite circular references like this, or is this okay to do? If this works, I'll close this issue. Thank you!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@millsp
Comment options

@nandorojo
Comment options

Answer selected by millsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #226 on March 31, 2021 09:50.