Skip to content

Typescript response definition #232

Open
@vincerubinetti

Description

@vincerubinetti

Might be nice to put a response.d.ts file in the repo so we could use it for using the response in TypeScript.

There are some tools that can help you out with this:

https://app.quicktype.io/?l=ts
https://transform.tools/json-to-typescript
https://json-5.com/json-to-typescript

Using one of them and this example query, here's a first pass at a schema:

export type Response = Result[];

type Result = {
  word?: string;
  phonetics?: Phonetic[];
  meanings?: Meaning[];
  license?: License;
  sourceUrls?: string[];
};

type License = {
  name?: string;
  url?: string;
};

type Meaning = {
  partOfSpeech?: string;
  definitions?: Definition[];
  synonyms?: string[];
  antonyms?: string[];
};

type Definition = {
  definition?: string;
  synonyms?: any[];
  antonyms?: any[];
  example?: string;
};

type Phonetic = {
  audio?: string;
  sourceUrl?: string;
  license?: License;
  text?: string;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions