Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can try this with typescript 4.1 :

interface User { name: string; age: number; }

type CapitalizeProperties<T> = { [Property in keyof T as Capitalize<string & Property>]: T[Property]; };

type CUser = CapitalizeProperties<User>;

var c : CUser = { Age: 17, Name: "john" }

You can check that the autocompletion works on the c variable.

https://www.typescriptlang.org/play?ssl=1&ssc=1&pln=15&pc=2#...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: