Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insertMany type is always never[] #542

Open
jessekrubin opened this issue Nov 4, 2023 · 5 comments
Open

insertMany type is always never[] #542

jessekrubin opened this issue Nov 4, 2023 · 5 comments

Comments

@jessekrubin
Copy link
Contributor

Describe the bug

When I try to use insertMultiple I ALWAYS get xyz is not assignable to never[]

To Reproduce

Try using insertMultiple and then running tsc. Can make a repro later. Currently at park with dogs.

Expected behavior

Types should infer correctly.

Environment Info

os: windows/ubuntu/rhel
Node: 18.18.1
Orama: 2.0.0-beta4

Affected areas

Data Insertion

Additional context

No response

@rosszurowski
Copy link

rosszurowski commented Nov 4, 2023

I just ran into this too. Looking at past issues, it looks like you need to use as const for the typings to work.

const db = await create({
  schema: {
    id: "string",
    title: "string",
    notes: "string",
  } as const, // the as const here is important
})

It looks like it's covered in the Typescript documentation page, but I didn't even notice they had a Typescript page, and instead was just relying on the create docs page.

@jessekrubin
Copy link
Contributor Author

@rosszurowski that semi-works for me, but I get some weird deviation between the return-type of search and the schema due to the readonlys from the as const. Fixable with some type-gymnastics tho.

@micheleriva
Copy link
Member

@rosszurowski good call. We will fix the docs adding TypeScript specifications on other pages 🙏

@jessekrubin
Copy link
Contributor Author

@micheleriva how can I make orama fuzzier? I am currently testing it out as a replacement for fzf-for-js which fuzzy matches more aggressively

@jacob-8
Copy link

jacob-8 commented Mar 18, 2024

@rosszurowski good call. We will fix the docs adding TypeScript specifications on other pages 🙏

Did this ever happen? I actually came across the as const in https://docs.oramasearch.com/open-source/usage/typescript and still didn't realize it was my problem because I recently ran into a "never" issue using Supabase because I did not have strictNullChecks set to true. So that took me down the wrong route to fix things until coming to this issue. Consider mentioning it in the Getting Started, Create, and Insert pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants