Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading