Within my code, I have constructs that resemble the following:
{
classNames: {
foo: 'foo',
....
bar: 'bar'
},
method1: () => {....},
method2: () => {....},
stringKey1: 'stringKey1',
...
stringKeyN: 'stringKeyN',
}
I am aiming to define a function parameter like so:
function func1(myObj) { ... }
However, my explanation is lacking
interface IMyObject {
classNames: [key: string]: string;
method1: Function;
method2: Function;
[key: string]: string | undefined;
}
The resulting issues are:
- The 'classNames' property, with type '[any, string]', cannot be assigned to the string index type 'string'.
- The 'method1' property, with type 'Function', cannot be assigned to the string index type 'string'.
- The 'method2' property, with type 'Function', cannot be assigned to the string index type 'string'.