This is pretty doable with mapped types in TS, to make it work without a compilation step though is pending on https://github.com/microsoft/TypeScript/issues/32063
Although in practice the mapped types to do this do slow down the typing service non trivially.