tobie / specref

An open-source, community-maintained database of Web standards & related references.
http://www.specref.org/
Apache License 2.0
165 stars 141 forks source link

Define TypeScript schema for responses #685

Open marcoscaceres opened 3 years ago

marcoscaceres commented 3 years ago

It be nice to have a TypeScript types file, for APIs that consume this.

(I've not had a chance to do something like this before, but would be useful for projects like ReSpec that consume this data)

CC'ing @saschanaz who may provide guidance? 🙏

I think what we need is described in: https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html

saschanaz commented 3 years ago

I haven't seen a type scheme defined without an actual library. Might be interesting to see an existing case.

marcoscaceres commented 3 years ago

I'm thinking of something like: https://www.npmjs.com/package/@types/pluralize

Where the types are delivered independently of the actual library.

I guess then also specref itself would also use them - though it's not really a library in the traditional sense.

saschanaz commented 3 years ago

That corresponds to the actual library named pluralize. Anyway there is @types/node which is obviously not a library and also @types/web-ie11, so probably doable.

saschanaz commented 3 years ago

BTW I think getting a JSON schema file would probably be better for multiple language support 👀

tobie commented 3 years ago

Like these?

saschanaz commented 3 years ago

Oh cool. Maybe use things like https://www.npmjs.com/package/json-schema-to-typescript to generate TypeScript lib then?