and lastname when building the template literals of same object?
export interface Person {
first_name: string,
last_name: string,
name: `${Person['first_name']} ${Person['last_name']}`
}
as above name prop type will be string.
or that is only possible by constructing the type from a literal expression (with const assertion)?
export interface Person<FirstName extends string, LastName extends string> {
function person <F extends string, L extends string>(first: F, last: L, name: `${F} ${L}`) { return { first, last, name }; } person( "Muthu", "Kumar", "" // Argument of type '""' is not assignable to parameter of type '"Muthu Kumar"'.(2345) )
Might as well just concat in there at this point
Обсуждают сегодня