Type issues in Search Builder

Type issues in Search Builder

chocchoc Posts: 133Questions: 14Answers: 12

Link to test case: https://github.com/DataTables/SearchBuilder/blob/master/src/interface.ts#L104

Description of problem: According to the doc, searchBuilder.rebuild() has two arguments, but the typing is missing the newly added boolean type redraw and the doc might also need be updated too. It says: searchBuilder.rebuild() takes one argument...

If I use:

dt.searchBuilder.rebuild()

I got: TS2554: Expected 1 arguments, but got 0

Same issue for the typing of searchBuilder.getDetails().

or

If I use:

dt.searchBuilder.rebuild(stored)

I got:

TS2345: Argument of type

Required<Pick<SearchBuilderDetails, "criteria">> & SearchBuilderDetails

is not assignable to parameter of type IDetails
Types of property criteria are incompatible.
Type SearchBuilderCriterion[] is not assignable to type Group[]
Type SearchBuilderCriterion is missing the following properties from type Group: classes, dom, c, s, and 23 more

If I use:

dt.searchBuilder.getDetails(false)

I got: TS2554: Expected 0 arguments, but got 1

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,793Questions: 1Answers: 10,945 Site admin
    Answer ✓

    Hi,

    Many thanks for letting me know about that error. I've committed a correction.

    With that change, the following will work correctly:

    import DataTable from "datatables.net-searchbuilder";;
    
    let api = new DataTable.Api('#example');
    
    let details = api.searchBuilder.getDetails();
    let deformattedDetails = api.searchBuilder.getDetails(true);
    
    api.searchBuilder.rebuild();
    api.searchBuilder.rebuild(details);
    api.searchBuilder.rebuild(details, true);
    api.searchBuilder.rebuild(details, false);
    

    Regards,
    Allan

Sign In or Register to comment.