I'm trying to build a function that returns a typed object through a function that explicility is passed the type
https://stackblitz.com/edit/typescript-uahcrj?file=types.ts
export interface M<TS = any> {
name?: string;
state: TS;
}
export const createModel = <TS>() => <
TM extends M<TS>
>(
mo: TM
): TM => mo
export type SharksType = {
values: number[]
amount: number
}
export const sharks = createModel<SharksType>()({
state: {
values: [],
amount: 1,
},
})
Actually, amount is correctly infered, but complex states like number[], it's defined like any[],
how can i do dynamically on every key of the state an as?
state: {
values: [] as number[],
amount: 1 as number,
},