dwn-sdk-js icon indicating copy to clipboard operation
dwn-sdk-js copied to clipboard

Use typescript utility types to define the index search instance

Open NWylynko opened this issue 2 years ago • 2 comments

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.

NWylynko avatar Jun 14 '22 12:06 NWylynko

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.

NWylynko avatar Jun 14 '22 13:06 NWylynko

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

mistermoe avatar Jun 24 '22 10:06 mistermoe

Submitted PR to update the type definition: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62613

Waiting on original author's approval.

thehenrytsai avatar Oct 10 '22 18:10 thehenrytsai

@NWylynko, one more gentle ping before merging directly from my PR branch to this main.

thehenrytsai avatar Oct 24 '22 18:10 thehenrytsai