You can do smth like that:
interface Square {
kind: "square";
size: number;
}
interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}
type Shape = Square | Rectangle;
type ShapeName = Shape['kind'] // 'square' | 'rectangle';
Please keep in mind, you are unable to obtain interface name unless you map some how it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…