Javascript 在typescript中使用jquery.handsontable
我想在typescript中使用handsontableJavascript 在typescript中使用jquery.handsontable,javascript,jquery,typescript,handsontable,Javascript,Jquery,Typescript,Handsontable,我想在typescript中使用handsontable $("#dataTable").handsontable({ data: data, startRows: 5, startCols: 5, minSpareRows: 1, contextMenu: true, onSelection: function (row, col, row2, col2) { var meta = container.handsontable('
$("#dataTable").handsontable({
data: data,
startRows: 5,
startCols: 5,
minSpareRows: 1,
contextMenu: true,
onSelection: function (row, col, row2, col2) {
var meta = container.handsontable('getCellMeta', row2, col2);
if (meta.isWritable == false) {
container.handsontable('updateSettings', { fillHandle: false });
}
else {
container.handsontable('updateSettings', { fillHandle: true });
}
},
cells: function (row, col, prop) {
var cellProperties = {};
if (row === 0 || container.handsontable('getData')[row][col] === 'readOnly') {
cellProperties.readOnly = true; //make cell read-only if it is first row or the text reads 'readOnly'
}
cellProperties.type = {
renderer: negativeValueRenderer
}
return cellProperties;
}
});
但我得到了错误:
Error 1 The property 'readOnly' does not exist on value of type ''.
Error 3 The property 'type' does not exist on value of type ''.
如何修复?TypeScript编译器不喜欢您的空对象。它没有关于其类型或其上可能存在的属性的信息 最简单的方法是:
var cellProperties:any = {}