DataTables / DataTables/React

TypeScript type mismatch for `ajax` and `options.ajax` props

Open
#8 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
6
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Hello, and thank you for developing this React component for DataTables.

I found that both the ajax prop and options.ajax prop work fine in practice, but they produce a TypeScript type error. The current type definition doesn’t seem to match what is described in the DataTables documentation:

https://github.com/DataTables/React/blob/a98eb61c7147f0e573c563b2e1397c785ff61909/Readme.md?plain=1#L53

Error message:

Object literal may only specify known properties, and 'url' does not exist in type 'AjaxSettings | FunctionAjax'.

You can reproduce the issue here:
https://stackblitz.com/edit/datatables-net-react-ajax-xmq14ri7?file=src%2FApp.tsx

In the example, the table renders correctly and data is loaded as expected, but TypeScript still reports a type error for the ajax option. As a short-term workaround, I’m currently adding @ts-expect-error above the line to suppress the error.

Could the type definition be updated to match the documented and working behavior?

Thanks again for building and maintaining this component.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documented usage in Readme.md at the linked section and reproduce the type error in the provided StackBlitz example. Trace the TypeScript definitions for the ajax and options.ajax props, then verify that the documented url form is accepted without an error while the table still loads data as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.