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

What about type annotations? #8

Open
apsavin opened this issue Mar 9, 2017 · 3 comments
Open

What about type annotations? #8

apsavin opened this issue Mar 9, 2017 · 3 comments

Comments

@apsavin
Copy link
Contributor

apsavin commented Mar 9, 2017

Hi, Yury!

Thanks for the useful lib!

A lot of programmers in JS community use flow and Typescript. My company uses flow, so I'm interested in flow mostly. Do you want to add annotations so the users of typed languges would benefit from it?

Here's the docs for flow and typescript for reference.

@yury-dymov
Copy link
Owner

Hi @apsavin,

I am using flow in my projects as well, and I considered to add it here.
I am a bit busy nowadays, so this might be shipped in a month from now or so.
PRs are welcome of course :)

@emp823
Copy link

emp823 commented Oct 21, 2018

Made a simple definition. Does not cover the actual transformations, that could probably be covered with generics.

declare module "json-api-normalizer" {
  export interface IJsonApiResponse {
    data: IJsonApiObject[]
    included?: IJsonApiObject[]
    links?: { [key: string]: string }
    meta?: { [key: string]: any }
  }

  export interface IJsonApiObject {
    attributes: { [key: string]: any }
    id: string
    links?: { [key: string]: string }
    meta?: {}
    relationships: {
      [key: string]: {
        data: IJsonApiReference | IJsonApiReference[]
        links?: { [key: string]: string }
        meta?: {}
      }
    }
    type: string
  }

  interface IJsonApiReference {
    id: string
    type: string
  }

  interface IOpts {
    camelizeKeys?: boolean
    camelizeTypeValues?: boolean
    endpoint?: boolean
    filterEndpoint?: boolean
  }

  function normalize(json: IJsonApiResponse, opts?: IOpts): {}
  export default normalize
}

@yury-dymov
Copy link
Owner

@emp823 looks great! Would be more than happy to accept a good PR, once ready

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

No branches or pull requests

3 participants