l-lin / angular-datatables

DataTables with Angular
https://l-lin.github.io/angular-datatables/
MIT License
1.57k stars 481 forks source link

Upgrade to DataTables.net v2 and swap out @types/datatables.net for the built-in types #1780

Closed pbarranis closed 2 months ago

pbarranis commented 3 months ago

:rocket: Feature request: DataTables.net v2 Support

DataTables.net v2.0.0 shipped in early March. This issue is to track progress towards support. Here's what's new in v2.

This issue was started based on a discussion, but choosing to copy all that text into this issue seems like it would just make things messy.

It's worth noting that, at this time, my project is about to target both angular-datatables 17.0.0 and datatables.net 2.0.2 in NPM and successfully build and deploy. The problem is in using the new v2 APIs (more on that in a comment below).

pbarranis commented 3 months ago

I think the only problem here is going to be that v2 overhauled many parts of their API with a ton of new features. People are going to want to use those new features. However, the necessary types to use those features are included in datatables.net, per the project owner's comment here. Here's a link to the published types in the source.

Since the project now publishes their own types, @types/datatables.net should be deprecated, and angular-datatables will need to update to use the new included types. But from what I can see, many of the names are different and there's no namespace. I'm not knowledgeable at dealing with how TypeScript types work, but they look incompatible to me.

pbarranis commented 3 months ago

I know @shanmukhateja said he wanted to keep angular-datatables backwards compatible with v2, but I don't think that's possible. The owner of the datatables.net project commented in the discussion that v1 is no longer supported.

I think the modern solution of simply creating a v1 branch and, if necessary, publishing an update to angular-datatables v1 on that branch, under a 1.17.x version number, would suffice.

Aside from this issue of compatibility with angular-datatables, my experience is that an update from datatables.net v1 to v2 is almost completely painless and error-free. Unfortunately, I spent a lot of time trying to figure out these type issues while trying to use the v2 API and almost no time fixing breaking changes in my use of datatables.net itself.

l-lin commented 2 months ago

The PR #1783 has been merged. Sorry for the delay.

Thanks again @shanmukhateja for the huge rework :+1:

I know @shanmukhateja said he wanted to keep angular-datatables backwards compatible with v2, but I don't think that's possible. The owner of the datatables.net project commented in the discussion that v1 is https://github.com/l-lin/angular-datatables/discussions/1777#discussioncomment-8862848.

We have decided to follow suit and only support DT v2 starting from v17.1.X, and as you mentioned, the migration to DT v2 should not be painful.

On a side note, the versioning of angular-datatables is a bit awkward as we are only trying to have the major version to be synchronized with Angular, so no link with DT version, which was ok until now. (Maybe semver is not the right answer for this project? It's another debate...)

Hopefully, the updated documentation should be clear enough that angular-datatables is now only supporting DT v2 (if it's not, maybe we should add a huge warning in the README.md for a few months).

shanmukhateja commented 2 months ago

Unfortunately we are breaking semver for this instance.

v17.1.0 is not backwards compatible.

Thanks to @l-lin for helping me review the code.

The new version is tagged and release is up on NPM.

The documentation will follow suit in minutes.

EDIT: Documentation is now up :-)

Cheers :)