'fixedColumns' does not exist in type 'Settings'

'fixedColumns' does not exist in type 'Settings'

vignesh424vignesh424 Posts: 2Questions: 1Answers: 0

Object literal may only specify known properties, and 'fixedColumns' does not exist in type 'Settings'.

I am working in Angular 4 . I use Jquery Datatables Fixed Columns . So that i installed the NPM for Fixed Columns . After I installl , i added the CSS and JS of fixed columns in .angularcli.json file . its properly added .After that i tried to add fixed column property in dtoptions i get this error " Object literal may only specify known properties, and 'fixedColumns' does not exist in type 'Settings'."

NPM packages which was i installed.

npm install jquery --save
npm install datatables.net --save
npm install datatables.net-dt --save
npm install angular-datatables --save
npm install @types/jquery --save-dev
npm install @types/datatables.net --save-dev

npm install --save datatables.net-fixedcolumns-dt

.angularcli.json

"styles": [
"src/styles.css",
"node_modules/datatables.net-dt/css/jquery.dataTables.css",
"node_modules/datatables.net-fixedcolumns-dt/css/fixedColumns.dataTables.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/datatables.net-dt/js/dataTables.dataTables.js",
"node_modules/datatables.net-fixedcolumns-dt/js/fixedColumns.dataTables.js"
]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Sounds like whatever typing information you are using is incorrect. If you aren't using any specific typing information then yes, you probably would get that error since the settings object is just a plain Javascript object and can be extended any way required by the extensions such as FixedColumns.

    If you can't disable that warning, I guess the only option would be to extend the settings object's definition.

    Allan

  • vignesh424vignesh424 Posts: 2Questions: 1Answers: 0

    How can we extend the Settings objects. I couldn't find any sample for that.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Its just an object so you could use:

    $.fn.dataTable.models.oSettings.myCustomProperty = ...;
    

    However, I would imagine TypeScript won't pick that up. You would probably need to do a bit of declaration merging - but we don't currently publish TypeScript definitions for DataTables. There have been a few thirdparty attempts that you might be able to build on though.

    Allan

This discussion has been closed.