Lookup typealias in enclosing declaration when writing type

and wouldn't it be sufficient to preserve the explicit type annotation if there is one. that means we miss union types, but that is fine..