Currently, std.traits.XXXTypeOf is implemented in tricky. To fix the complexity, I'd like to propose a new __trait.
alias Seq(T...) = T;
alias TypeTuple = Seq;
import std.typetuple;
struct S1
{
string var;
alias var this;
}
static assert(__traits(getAliasThis, S1) == TypeTuple!("var"));
// __traits(getAliasThis) returns a tuple of alias this member names
static assert(is(typeof(__traits(getMember, S1.init, __traits(getAliasThis, S1)[0])) == string));
// Extract the alias this type by using the combination with __traits(getMember).
struct S2
{
TypeTuple!(int, string) var;
alias var this;
}
static assert(__traits(getAliasThis, S2) == TypeTuple!("var"));
static assert(is(typeof(__traits(getMember, S2.init, __traits(getAliasThis, S2)[0])) == TypeTuple!(int, string)));