I think we can define class using types as follows.
First, prepare the type $\mathbb{S}$ for sets.There are initial elements of type $\mathbb{S}$ such as the empty set. If you don't want numbers $0, 1, 2, ...$ to have structure such as $0 \in 1$, you can think them as initial elements.
There are construction rules which states the existence of a new element of type $\mathbb{S}$ based on known elements of type $\mathbb{S}$. For example, if $A$ and $B$ are sets, $A \times B$ and $A^B$ are sets. They are something like functions $\mathbb{S}\times \mathbb{S}\to\mathbb{S}$.
After the initial elements and construction rules are determined, "all elements of type $\mathbb{S}$" is determined. We can think it as a set and I will write it as $S$.
Next, prepare the type $\mathbb{C}$ for class.
The initial elements of type $\mathbb{C}$ are that of $\mathbb{S}$ plus $S$. The construction rules of $\mathbb{C}$ are that of $\mathbb{S}$. Namely, if $f:\mathbb{S}\times\mathbb{S}\to\mathbb{S}$ is a construction rule, there is a corresponding construction rule $\overline{f}:\mathbb{C}\times \mathbb{C}\to \mathbb{C}$.
Because the initial elements and construction rules are determined, "all elements of type $\mathbb{C}$" is determined and I will write it as $C$.
Finally, I define classes as the elements of $C$ and sets as the elements of $S$. A proper class is an element of $C-S$.
The above argument is not strict and for example I need to list all the construction rules.
Is there any research on defining classes this way?
@Roddy MacPhee
This is not a duplicate of Reference request: definition of class. The linked question is general one about an arbitrary definition of class. This question is about the specific technique. The linked question does not answer this question. (However, this question may give some kind of answer to the linked question.)
The universe $U$ in Martin-Löf's intuitionistic type theory is close.
The difference is that the construction in ITT is not graded (namely, there is not the type for classes other than the type for sets) and $U$ is a set.