How do you have a type typed "Type" when implementing a programming language? I am working on the base of a language model, and am wondering how to represent the base type, which is a type Type. I have heard of an &quot;infinite chain of types&quot;, but (a) I can't seem to find it on the internet while searching anymore, and (b) I am not sure if that's what I need or what it really means in practice.
Basically, I have a system in the language like this:
type User
type String
type X
...

Internally these get compiled to something like this:
[
  {
    type: 'Type',
    name: 'User'
  },
  {
    type: 'Type',
    name: 'String'
  },
  ...
]

But actually, the type: 'Type' gets further compiled not pointing to the string 'Type', but to the actual Type object:
[
  {
    type: theTypeObject,
    name: 'User'
  },
  {
    type: theTypeObject,
    name: 'String'
  },
  ...
]

So then the problem is, I need to now define or specify the &quot;type type&quot; itself:
type Type

which I try represent in a similar way, so now we have:
[
  {
    type: 'Type',
    name: 'Type'
  },
  ...
]

which is:
let theTypeObject = { name: 'Type' }
typeTypeObject.type = theTypeObject

Is that correct? What is this really saying? It is a circular structure, does this even make sense conceptually?
What would be better to do in this situation? Or is this perfectly acceptable? Basically I would like to understand how to explain what this circular structure even means, because it just makes me confused.

The type &quot;Type&quot; is typed &quot;Type&quot;. It is an element of itself...

That doesn't seem logically possible. So what should I do?
I think what you might have found in your previous researches might be a pure type system.
In a pure type system, to avoid having &quot;Type&quot; being a &quot;Type&quot; at the same level that &quot;Int&quot; is a &quot;Type&quot;, you would define another layer of &quot;Types&quot; where you would define &quot;Type&quot; as the entire first layer (and you would define this layer in the next one, and so on)
In practice, you could define your base types as &quot;types&quot;, and the next layer would be kinds. The type &quot;type&quot; would be a kind. You might also want to consider functions of types to types as another kind.