If you check the source for the Required type, it’s this:
type Required<T> = {
[P in keyof T]-?: T[P]
}
The same syntax can be used to construct a generic type that will give you what you want:
type User = {
id: string
name?: string
email?: string
}
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }
type UserWithName = WithRequired<User, 'name'>
// error: missing name
const user: UserWithName = {
id: '12345',
}
Playground link