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

@findify/sdk: Typescript types largely unusable due to enum usage #809

Open
simonlovesyou opened this issue May 2, 2022 · 2 comments
Open

Comments

@simonlovesyou
Copy link

simonlovesyou commented May 2, 2022

When using @findify/sdk (version 2.2.3) it is not possible to use the included typescript types since most "Request" definitions depend on enums which are not exported in the distributed code.

import type { Search } from '@findify/sdk/types/request'
import { init } from '@findify/sdk'

const client = init({ /* configuration */ })

const search = (query: Search.Params['q']) => {
  const request: Search.Request = {
    type: 'search', // Type '"search"' is not assignable to type 'Type.Search'.ts(2322)
    params: {
      q: query
    }
  }
  return client.send(request)
}

We cannot import Type and use as replacement for the search string since it's an enum. We need to either able to import a js file with a separate type declaration for the enum OR type is specified with a const string instead for the different requests

@timaramazanov
Copy link
Contributor

@simonlovesyou Hey, thanks for discovering this!
We've released new SDK version: @findify/[email protected] where you'll be able to import RequestType:

import { RequestType } from '@findify/sdk';

Can you pls check how it works for you?

@simonlovesyou
Copy link
Author

Thanks for the fix @timaramazanov ! I can see in my editor that typescript is satisfied, the added docs looks great too! Unfortunately I can't run our application and test it because we're blocked from upgrading by #796 :/

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

2 participants