dwn-sdk-js
dwn-sdk-js copied to clipboard
Use typescript utility types to define the index search instance
A better solution would be for @types/search-index
to be updated and have the types exported. But until that is done, using the inbuilt typescript util types works. A type error is raised on line 82 because index.QUERY
returns an object with RESULT
according to the types but on line 82 RESULTS
is being pulled out of the object. I am assuming that RESULTS
is correct and that the types are out of date / wrong so I have not changed it in my commit.
After looking at the search-index
source code it looks like the types are correct and that RESULT
is the field returned in the object for a QUERY
. Running the node tests I don't get an error either way (besides the type error) so it looks like there isn't tests for this part of the code. For now I will leave it as RESULTS
as I am assuming that this code has been used by other services and websites and works, but I can easily fix this type error.
Sorry for the delay here! been head's down working my way through a large refactor. You're totally right, there weren't any tests that hit the codepath in question. I ran into an error the moment i wrote a test and ended up fixing it on the refactor branch i've been working in here
Submitted PR to update the type definition: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62613
Waiting on original author's approval.
@NWylynko, one more gentle ping before merging directly from my PR branch to this main.