score:0

Accepted answer

your biggest issue here is that you are specifying the type any everywhere, which defeats the point of typescript and won't help you learn.

you need to set the return type on the function as typescript is inferring its type from the first value you are returning in the tuple.

if you tell typescript what to expect it won't infer anything.

you can define a tuple in the same shape as you want the return:

type storereturn = [((store: any) => any) | undefined, (action: any) => {}, () => {}];

then when you define the function you specify the return type

const createstore = (initialstore: any): storereturn => { 
  // your code 
} 

doing this in your sandbox got the correct result for me. typescript has incredible documentation and i encourage you to give it a go. a good practice for me was to set strict rules in tsconfig to not allow the use of any like this.


Related Query

More Query from same tag