I'm trying to figure out a way to get rid of this error "Property 'pending' of type 'boolean' is not assignable to 'string' index type"
I've found this stackoverflow: arbitrary type definition gives: Property 'x' of type 'boolean' is not assignable to string index type 'string'
it's not the exact same but I tried to take the logic and do something similar but no success.
Here is what I've tried so far
type MyObj<K extends keyof any> ={ [P in K]: Record<P, string> & { btnWrap: boolean } };
const asMyObj = <T extends MyObj<keyof T>>(myObj: T) => myObj;
let myObj31 = asMyObj({ key1: 'val1', pending: true});
// -------------
type InnerObj = {
[key: string]: string | boolean;
pending: boolean;
};
const myObj32: InnerObj = { pending: true, key1: { id: 'val1' }, key2: { id:'val2'} };
// -------------
type customType = {
[key: string]: { id: string };
pending: boolean;
};
const myObj33: customType = { pending: true, key1: { id: 'val1' }, key2: { id:'val2'} };
// Some of these taken from https://stackoverflow.com/questions/55244493/arbitrary-type-definition-gives-property-x-of-type-boolean-is-not-assignabl
Thanks for any help!