Skip to content

Typescript response definition #232

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

Open
vincerubinetti opened this issue Apr 4, 2025 · 0 comments
Open

Typescript response definition #232

vincerubinetti opened this issue Apr 4, 2025 · 0 comments

Comments

@vincerubinetti
Copy link

vincerubinetti commented Apr 4, 2025

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;
};
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

1 participant