Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何将值传递给TypeScript中在函数参数中传递名称的属性?_Node.js_Typescript_Eslint - Fatal编程技术网

Node.js 如何将值传递给TypeScript中在函数参数中传递名称的属性?

Node.js 如何将值传递给TypeScript中在函数参数中传递名称的属性?,node.js,typescript,eslint,Node.js,Typescript,Eslint,我收到eslint/typescript错误: errorUnsafe member access .value on an any value @typescript-eslint/no-unsafe-member-access 尝试将值保存到动态属性名称时: selectChange(name: string, value: string) { if(this[name] && typeof this[name].value === "string&q

我收到eslint/typescript错误:

errorUnsafe member access .value on an any value
@typescript-eslint/no-unsafe-member-access  
尝试将值保存到动态属性名称时:

selectChange(name: string, value: string) {
    if(this[name] && typeof this[name].value === "string") {
      this[name].value = value
    }
  }
我添加了if语句,但它没有帮助,是否有可能以正确的方式执行它?或者我必须更改eslint配置文件。

好的,我有解决方案:

在上面的某个地方声明:

type column = 'property1' | 'property2'
并从方法中删除不必要的if语句:

selectChange(name: column, value: string) {
    this[name].value = value
}

它会工作得很好。

这个
有一个类似
[index:string]:string?@Anatoly nevermind,我有一个问题的快速解决方案