I don't think this is typescript error, there are some problems with this code
const {[name]: value} = o ;
what kind of string is it, you define a constant without a name, and then use something like type and assign o
And what is it value
?
Since I don’t know what your idea was, I can offer these codes:
If you want to consider it as a type
const x : {[name:string]:string} = o;
If you want to use it as a value
const x = {[name] : 'my value'};
source
share