Say I have the following object:
const obj = {
foo: "bar",
hello: "world",
}
and the following object processing function:
const process = (obj) => {
const processedObj = {}
for (const key in obj) {
processedObj[`--${key}`] = obj[key]
}
return processedObj
}
How can I type key
argument to only accept processed keys that start with --
?
const processedObj = process(obj)
const getValue = (key) => {
return processedObj[key]
}
Trying to programatically convert JS object properties to CSS variables so that Visual Studio Code IntelliSense feature suggests getValue("--foo")
when typing getValue("--f")
.