I want to declare a variable with two types via TypeScript, but the compiler gives me a type error.
interface IAnyPropObject {
[name: string]: any;
}
let a: IAnyPropObject | ((str: string) => any);
a.b = "bbbbbbbb"; /* type error */
a(""); /* type error */
I don't want to use any to declare.
I just want to constrain the variable to be only these types.
Because the code are so old and they are not TypeScript code.
aso you cannot assign a property on it.