Yes, this is correct. In TypeScript, you can index a type to get the type of the property of that key (see Indexed Access Types). Basing a type on the value of an object's property is impossible, as TypeScript runs at compile time and values are determined at runtime. If you had a type "john" then that is what would show up:
type John = {name: "john"};
let yourName: John["name"];
TypeScript Playground
You can see that the type of yourName is then "john". By default, TypeScript assumes that the object will change, so the type of
let me = {name: "john"};
is inferenced as {name: string} (TypeScript Playground). If it was {name: "john"} by default, then you couldn't change it to something else. Most of the time, when you declare an object, you're going to change it, so this is the safe assumption to make.
T[k]is an Indexed Access Typestringand not just value "john"?"john"is eitherstringwhen typescript assumes that it's variable or more narrowed down only the exact string'john'Literal Types which happens when typescript assumes it can't change. But it's still a subtype of string and can therefore be assigned to the broaderstringtype.