can I pass a normal javascript object to typescript utility type Record<string, string>

68 Views Asked by At

I need to set this property:

enter image description here

but this property was from external npm module written with typescript, launchParams requires a Record<string,string> type. my question is what is the exact way and the exact data to pass to set the value of launchParams ?

I tried to set launchParams with this:

launchParams: {"homeurl" : "https://localhost"}

but it seems it doens't work. launchParams is still undefined.

1

There are 1 best solutions below

2
matt helliwell On

Assuming you meant to type 'launchParams:' and not 'lunchParams', then the problem looks like you are defining the type of launchParams and not assigning a value to it. Try

launchparams = {"homeurl" : "https://localhost"}

If that doesn't work you need to give more details, preferably a working example on Stackblitz that shows the problem.