DataTables / DataTablesSrc

DataTables source repository
https://datatables.net
MIT License
587 stars 422 forks source link

functions and options missing from types but seem to be still present/available #214

Closed hchiam closed 1 year ago

hchiam commented 2 years ago

Hi! I'm trying to upgrade DataTables from v1.10 up to v1.12.1 for a private project, but it seems that a few different functions and options were taken away in the updates as early as v1.11, but when I run the project I can still see these options are available in the console log in dev tools. Are the functions in the diffs for this PR all coming from https://github.com/DataTables/Select/blob/master/types.d.ts ? and the additions to interface Settings at the bottom of the diffs in this PR?

hchiam commented 2 years ago

Below are a couple demos. The code itself works, but the private project can't build because the types failed, which makes me think that the types for https://github.com/DataTables/Select didn't get installed properly for some reason.

AllanJard commented 1 year ago

Hi - thanks for the PR.

Those methods and options are defined in Select's own types.d.ts file: https://github.com/DataTables/Select/blob/master/types.d.ts since that is the software that defines those options, rather than DataTables itself.

hchiam commented 1 year ago

Hi - thanks for the PR.

Those methods and options are defined in Select's own types.d.ts file: https://github.com/DataTables/Select/blob/master/types.d.ts since that is the software that defines those options, rather than DataTables itself.

Ah yes, as I suspected. Thanks @AllanJard!

I tried installing/adding datatables.net-select to the private project's package.json deps, but the types still seem to be coming from the datatables.net types definition file. Thoughts? I must be missing something still.

datatables.net-select types seemingly not working or providing .select()

https://datatables.net/reference/api/row().select()#:~:text=this%20property%20requires%20the%20select%20extension%20for%20datatables.

I uninstalled @types/datatables.net because it seems to be out of date (latest is still 1.10.19), and because datatables.net@1.12.1 seems to ship with its own types.

hchiam commented 1 year ago

oh https://github.com/DefinitelyTyped/DefinitelyTyped/commit/3e1d0b037f49c431aafec0f3a4ad4184c0c45471 i will have to figure out why .select() doesn't show up for me on intellisense, even though select() is clearly in the interface RowsMethods for @types/datatables.net@1.10.22

hchiam commented 1 year ago

I'll close this PR since I've figured out what needed to be updated.

For others' reference: I needed to do 2 things to get .rows().select() to work when upgrading from datatables.net from 1.10 to 1.12:

  1. update @types/datatables.net to 1.10.22 (because of https://github.com/DefinitelyTyped/DefinitelyTyped/commit/3e1d0b037f49c431aafec0f3a4ad4184c0c45471 mentioned earlier)

  2. edit my existing code from this:

    dt.DataTable().rows({ search: 'applied' }).select();

    to this:

    dt.DataTable({ select: true }).rows({ search: 'applied' }).select();

    as per the docs: https://datatables.net/extensions/select/#:~:text=%24('%23myTable').DataTable(%20%7B-,select%3A%20true,-%7D%20)%3B