Basically what I'm trying to achieve is prevention of certain properties of an existing object to be passed as arguments to an interface. I believe this is possible through some combination of conditional types, but having a hard time working out the right combination.
export interface Dictionary<T> {
[index: string]: T;
}
type StandardContext = {
myKeyOne?: string;
myKeyTwo?: number;
}
type NonStandardContext = Exclude<Dictionary<any>, StandardContext>
const standard: StandardContext = {
myKeyOne: '2', // ok!
}
const nonStandardError: NonStandardContext = {
myKeyOne: '2' // should error (good so far)
}
const nonStandardGood: NonStandardContext = {
foo: '2' // should not error, but it does!
}