Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.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
TSLint:JavaScript map.set()函数未引发模型外主干get set错误_Javascript_Typescript_Tslint - Fatal编程技术网

TSLint:JavaScript map.set()函数未引发模型外主干get set错误

TSLint:JavaScript map.set()函数未引发模型外主干get set错误,javascript,typescript,tslint,Javascript,Typescript,Tslint,我正在使用Microsoft的tslint Microsoft contrib修复lint错误。它抛出以下错误,我认为这是一个错误警报 Backbone set()在所属模型外部调用 var mapSet = new Map(); mapSet.set('base', { id: 'base', label: 'label', type: 'type' }); // Error shown here

我正在使用Microsoft的
tslint Microsoft contrib
修复lint错误。它抛出以下错误,我认为这是一个错误警报

Backbone set()在所属模型外部调用

var mapSet = new Map();
mapSet.set('base', {     
            id: 'base',
            label: 'label',
            type: 'type'
        }); // Error shown here: Backbone set() called outside of owning model: mapSet.set('base'...) (no-backbone-get-set-outside-model)

有什么办法可以解决这个问题吗?

根据您提到的规则中的问题注释,这是一个特定于主干网的规则,因为您的案例与主干网无关,您可以在
tslint.json

中禁用它。奇怪的是,将字符串
'base'
指定给一个变量会使错误消失。var base=‘base’;set(base,{id:'base',label:'label',type:'type'});注意:此lint错误仅与Backbone.js相关。如果不使用Backbone.js,则可以禁用此错误。您也可以忽略此行的规则:
//tslint:disable next line:no Backbone get set out model
某些环境(PowerBI)要求您提交代码,但不更改tslint.json。