≡

TypeScript: missing Feature export causes errors with Buttons in layout

TypeScript: missing Feature export causes errors with Buttons in layout

peter.brunspeter.bruns Posts: 13Questions: 9Answers: 0

Link to test case: https://stackblitz.com/edit/vitejs-vite-nmcbfq6r?file=src%2Fmain.ts,package.json&terminal=dev
Description of problem:

Hi,

I'm using DataTables 3.1.5 and Buttons 4.1.3 with TypeScript.

TypeScript rejects buttons insidelayout.top1.features and layout.top1.buttons, reporting that it does not exist in the feature type.

Core declares Feature and uses it for the layout types, but doesn’t export it. Adding Feature to the export type list in datatables.net/types/types.d.ts resolves the error.

export type { Feature };

Could this export be included in the next release?

Thanks!

Replies

  • allanallan Posts: 66,190Questions: 1Answers: 11,042 Site admin

    Hi,

    I've got the fix locally, but github git services are currently down as I write this, so I've not been able to push it up yet. It will be in the next release though :).

    Allan

  • hodoninskahodoninska Posts: 20Questions: 2Answers: 0

    Hi Allan,

    I've encountered the same problem and have coded a local fix for it for the time being.

    I've had to do the same thing for ConfigColumnDefs, ConfigLanguage, plus ConfigSelect in the Select extension.

    In order to expose the scroller option I've had to add this with the 'declare module 'datatables.net'' block, which may or not be the correct solution but it has worked for me:
    interface Defaults {
    scroller?: boolean | Config;
    }

    I've also found that ConfigSelect and the Editor formOptions require all of their properties to be specified. I think they should all be defined as optional. My code looks like this at the moment and I only want to specify onBlur:
    formOptions: {
    inline: {
    onBlur: 'submit',
    buttons: undefined,
    drawType: false,
    focus: "",
    message: "",
    nest: false,
    onBackground: "submit",
    onComplete: "close",
    onEsc: "submit",
    onFieldError: "none",
    onReturn: "submit",
    refresh: false,
    scope: "cell",
    submit: "all",
    submitHtml: "",
    submitTrigger: 0,
    title: ""
    },
    bubble: undefined,
    main: undefined

    David

  • allanallan Posts: 66,190Questions: 1Answers: 11,042 Site admin

    Hi David,

    For Scroller, I've just added this commit - thanks for letting me know about that error.

    And for Editor, good catch there as well. I've committed the fix for that and will get a new release out soon.

    I'll need to look at the Select issue further.

    Many thanks for letting me know about these!

    Allan

  • hodoninskahodoninska Posts: 20Questions: 2Answers: 0

    You're very welcome Allan. It's a great product and I've very pleased to play a small part in making it even better.

  • hodoninskahodoninska Posts: 20Questions: 2Answers: 0

    Hi Allan,

    I've found another issue with the TypeScript definitions. The datetime property has been added to the Language interface by the DateTime extension but it is not optional, therefore I have had to modify my code to specify this property:

    const langOption: DataTable.ConfigLanguage = {
    search: '',
    searchPlaceholder: 'Filter…',
    emptyTable: emtpyTable,
    datetime: undefined
    };

    Regards,
    David

  • allanallan Posts: 66,190Questions: 1Answers: 11,042 Site admin

    Hi David,

    Many thanks for noting that. As a workaround at the moment you can do:

    import DataTable, { Options } from 'datatables.net';
    
    const langOption: Options['language'] = {
      search: '',
      searchPlaceholder: 'Filter…',
      emptyTable: emtpyTable
    };
    

    However, I agree that the ConfigLanguage interface should be optional and contain optional parameters. I'm looking into that, but I've not quite got it right yet... I'll post back with an update in due course.

    Allan

Sign In or Register to comment.