type style = "left" | "right" | "center"; const value: { [key in style]: key } = { left: 'left', right: 'right', center: 'center', } function printText(s: string, alignment: style) { // ... console.log(alignment) } // This will work fine printText("Hello, world", value.left); // This will cause a TypeScript error because 'up' is not a valid value for 'left' // printText("Hello, world", value.left as style);