Let me explain the issue in a simple way
I have a type consisting of predefined strings like:
type myType = 'name' | 'age' | 'family' | 'other';
I want to define a type that enforces these strings to be used
const myObject: myCastType<myType> = {
name: 'string',
age: 'string',
family: 'string',
other: 'string',
}
What I need to create is myCastType
The missing piece is how to mandate an object to have properties named after the supplied types
To clarify, I don't want to explicitly declare a type like:
type Person = { name: string, age: string, family: string, other: string }
const myObject: Person = { ... }
The challenge is that the specific properties like 'name', 'age', etc. are unknown and may vary in different implementations, requiring dynamic definition
I've attempted various methods like Pick, Record, Extract, etc., but haven't found a solution yet
If anyone has suggestions or can point me in the right direction with relevant resources, please feel free to share