ich mein Gehirn Abstich, warum der folgende Code nicht kompiliert:Typoskript TS2322 Fehler beim Lookup-Typen mit
interface Circle { type: "circle"; }
interface Rectangle { type: "rectangle"; }
type Shape = Circle | Rectangle;
interface Circle { type: "circle"; }
interface Rectangle { type: "rectangle"; }
type ShapeTemplate = {
type: Shape["type"];
};
const fromTemplate = (template: ShapeTemplate): Shape => template;
Es bricht mit:
TS2322: Type 'ShapeTemplate' is not assignable to type 'Shape'. Type 'ShapeTemplate' is not assignable to type 'Rectangle'. Types of property 'type' are incompatible. Type '"circle" | "rectangle"' is not assignable to type '"rectangle"'. Type '"circle"' is not assignable to type '"rectangle"'.