There's no way to do that. type(of:) is a normal function returning a metatype variable. You can't use variables where type is expected, and there's currently no way to define a type that is the same as that variable, well, other than the usual let b = a.
Note that type(of:) returns the dynamic type of a variable.
You are correct that we could something that gives you the static type, but since it is knowable at compile time, it is also knowable to you, so this would not enable anything that you can't already write today. There is no such feature in the language today.
Don't know whether Swift will support this feature in the future. When the type is complex, I really need such feature instead of annotating by myself.
You can build something like this easily if you want even for the standard types (Int, Double, String). Looks like you want to do so only for the custom types you are defining. And this can be done using something like below with help of a protocol
protocol Initializable {
init ()
}
class A : Initializable {
var content:String
requiredinit () {
content = "TestContent"
}
}
func createInstance(typeThing:T.Type) -> T where T:Initializable {