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

TypeScript Support #128

Open
damonwildercarr opened this issue Sep 7, 2017 · 13 comments
Open

TypeScript Support #128

damonwildercarr opened this issue Sep 7, 2017 · 13 comments

Comments

@damonwildercarr
Copy link

Thanks for the hard work on this - great project.

Any plans to include type definitions for TypeScript?

@mtth
Copy link
Owner

mtth commented Sep 8, 2017

Typings would definitely be welcome. I doubt I'll have time to dig into TypeScript enough to add them anytime soon unfortunately; I'll keep this open in case someone else would like to take a stab at it. Thank you for the kind words and bringing this up!

@andrew8er
Copy link
Contributor

I have an incomplete version here: https://github.com/andrew8er/avsc/tree/feature/typescript-definitions

I am pretty sure there are some errors, since I'm only really using a small part of the API so far.

@mtth
Copy link
Owner

mtth commented Nov 4, 2017

Thanks @andrew8er! Can you submit a PR with what you have so far?

@andrew8er
Copy link
Contributor

#134

@mtth
Copy link
Owner

mtth commented Nov 18, 2017

Merged - thanks @andrew8er. Keeping this open since the typing file isn't complete yet.

@TysonAndre
Copy link
Contributor

TysonAndre commented Jan 9, 2018

What's the intent for the package https://www.npmjs.com/package/@avro/types ?

  • I don't see it mentioned in this repo's issues
  • Grepping the source code, I don't see @avro/types
  • @avro/types doesn't have a README on NPM

Also, publishing declarations that are neither in "@types/avsc" nor packaged with "avsc" is non-standard and surprising. I proposed #146 ("bundling with your npm package") , but closed it since I'm not sure what the long term plan is.

According to https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/declaration%20files/Publishing.md

Now that you have authored a declaration file following the steps of this guide, it is time to publish it to npm. There are two main ways you can publish your declaration files to npm:

  1. bundling with your npm package, or
  2. publishing to the @types organization on npm.

@mtth
Copy link
Owner

mtth commented Jan 11, 2018

Hey @TysonAndre, thank you for the publishing tips. I'd created the @avro/types package to hold the Avro type decoding/encoding logic from avsc: a long term effort to split avsc into modular components, unfortunately stalled for now. It isn't at all related to TypeScript so it sounds like the best option is to include the types/ folder in this package.

@yonkeltron
Copy link

Any status on this work? It's a really terrific initiative so I'm not nagging, just excited!

@mtth
Copy link
Owner

mtth commented Feb 21, 2018

@yonkeltron - still a WIP but we already have reasonably complete typings thanks to @andrew8er and @TysonAndre.

@yonkeltron
Copy link

Roger! I'll pass it along to my teammates and we can try it out. Thanks for the hard work!

@reuzel
Copy link
Contributor

reuzel commented May 11, 2018

Just added a pull request to improve the typings...

mtth pushed a commit that referenced this issue Sep 27, 2018
Tweak typings

+ Make options in `forProtocol` optional
+ Add optional transport to `ClientOptions`
@RandomFractals
Copy link

shameless plug: you can see how I use it in TS here: https://github.com/RandomFractals/vscode-data-preview/blob/master/src/data.providers/avro.data.provider.ts

@slifty
Copy link

slifty commented Jun 21, 2022

I apologize for commenting without being able to dedicate time to opening a PR, but wanted to point out this really handy set of features that live in AJV: https://ajv.js.org/guide/typescript.html

In particular, it would be amazing if:

  1. payloadAvroType.fromBuffer would be smart enough to be able to signal the type of object that is returned.
  2. avro.Type.forSchema would be able to take a type / validate that the schema aligns with that type.

I hope these ideas make sense

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

8 participants