I have an object like
interface PageDef = {url: string}
const page1Def: PageDef = {url: "page1"}
const page2Def: PageDef = {url: "page2"}
const pages = {page1: page1Def, page2: page2Def}
Now I would like the pages type to be the following:
{{page1: PageDef, page2: PageDef}}
The issue is that page could have any name, for instance I could have
const pages = {home: page1Def, about: page2Def}
I do not want to use any of the following, as I would loose the keys in the type
const pages: {[pageName: string]: PageDef} = {page1: page1Def, page2: page2Def}
const pages: Record<string, PageDef> = {page1: page1Def, page2: page2Def}
I wouldnt be able to do something like the following to have a union type of page name
keyof typeof pages
// would be string with above definition
Not typing would have Typescript to dynamically type pages, which would partially solve my problem but would type check the values.
So my question is, is it possible to manually type only the value of an object? Or is there any other solution?