Skip to content

Default generic parameter undefined doesn't satisfy DocumentData #511

@mdtusz

Description

@mdtusz

When trying to build a project that is using v0.8.205, there's errors due to the types in index.d.ts not meeting constraints.

node_modules/flexsearch/index.d.ts:208:20 - error TS2344: Type 'undefined' does not satisfy the constraint 'DocumentData'.

208         ? Resolver<undefined, W, S>
                       ~~~~~~~~~

node_modules/flexsearch/index.d.ts:943:34 - error TS2344: Type 'undefined' does not satisfy the constraint 'DocumentData'.

943         D extends DocumentData = undefined,
                                     ~~~~~~~~~

node_modules/flexsearch/index.d.ts:961:34 - error TS2344: Type 'undefined' does not satisfy the constraint 'DocumentData'.

961         D extends DocumentData = undefined,
                                     ~~~~~~~~~

node_modules/flexsearch/index.d.ts:1023:34 - error TS2344: Type 'undefined' does not satisfy the constraint 'DocumentData'.

1023         D extends DocumentData = undefined,
                                      ~~~~~~~~~

This appears to be due to specifying undefined with the intent of making the document data type a required generic type parameter, but is invalid - rather, these generics should be either left undefined so that they are required, or the default concrete type DocumentData should be used instead (if it is desirable to make it an optional generic parameter).

While this can be circumvented by specifying "skipLibCheck": true in the tsconfig.json, that's not really a great solution long term and weakens the type safety that can be provided.

Let me know what you folks would prefer and I'm happy to open a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions