This doesn't need magic powers. All you have to do is treat literal values inside type descriptions differently.
Both of these are valid inferences, and it's impossible to know which one the user wants in the general case, which is why you have to explicitly say `const foo = {k: 'x' as const}`.
I feel like I'm missing something.
function test(p: {k: false | 'x' | 'y' | undefined}) {
// do stuff
}
const p = {k: 'x'} // inferred type: {k: string}
//...
test(p); // type error : Type 'string' is not assignable to type 'false | "x" | "y" | undefined'
The problem is that the type of p.k is inferred to `string` not `x`. The compiler can't know this is fine because you could call `foo(p)` in between the declaration and the `test` call, that mutates p.k.If you add `as const` or an explicit type to p it is fine.
(I think this is what the GGP was referring to)