Below I have an object with uses a dynamic key of string. I know there will never be overlap between the dynamic key and _meta
in real use, but how can I explicitly tell typescript that _meta
should always be treated as the object specified, rather than as Highlight
?
type FullHighlighter = {
_meta: { /* special object */ }
[highlightID : string] : Highlight
}
// Property '_meta' of type 'string' is not assignable to 'string' index type 'Highlight'
For example I thought this might work, but it didn't:
type FullHighlighter = {
_meta: { /* special object */ }
[highlightID : Exclude<string, "_meta">] : Highlight
}
Thanks!