You first need to assert the type of u and then change u.type's value.
u
u.type
(u as U).type = "y";
or if you want to assert u as Y you will have to assert it as unknown first because X and Y don't overlap.
Y
X
(u as unknown as Y).type = "y";