[] ){ return this.store$.select(getModuleMeasures(modules)); } I do" /> [] ){ return this.store$.select(getModuleMeasures(modules)); } I do" /> [] ){ return this.store$.select(getModuleMeasures(modules)); } I do"/>

Value for the parameter: func(Pick<Module, "id">[])

27 Views Asked by At

I have a function like the following

getModuleMeasures(
modules: Pick<Module, "id">[]
){
return this.store$.select(getModuleMeasures(modules));
}

I don't know what type of value that needs to be passed as an argument.

I tried passing the module id's as the parameter but it is not accepting. when i try to pass the id as string throws Type 'string' is not assignable to type 'Pick<Module, "id">'. error.

1

There are 1 best solutions below

0
nullptr On BEST ANSWER

The parameter needs to be an array of objects, which will have one key, id. The type of the value of id will be whatever it is in Module

type Module = {
  id: string, 
  abc: number
}
function getModuleMeasures(modules: Pick<Module, "id">[]) {
  console.log(modules)
}

getModuleMeasures([{id:'123'}])

playground