Problem Statement
Key remapping syntax:
Explanation
Use “as NewK” in a mapped type to rename keys while iterating over them.
Code Solution
SolutionRead Only
type PrefixKeys<T> = {
[K in keyof T as `app_${Extract<K, string>}`]: T[K]
};Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Typescript · Interview Question
Detailed answer, explanation and code for this interview question. Ideal for Typescript interview preparation, coding rounds and viva questions.
Key remapping syntax:
type PrefixKeys<T> = {
[K in keyof T as `app_${Extract<K, string>}`]: T[K]
};
Master Typescript with our complete collection of questions, tutorials and guides.