-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Types for typescript? #93
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue. |
Hi @johndcarmichael. I don't have much experience with TypeScript. Parser is pure JS but the models have pretty good jsdoc, maybe these could be used to genereate types? there are some tools https://github.com/otris/jsdoc-tsd. No one is working on it at the moment, and full focus is on 1.0 release and as high coverage of spec validation as possible. |
Maybe In free time I tried to create types from JSON Schema spec by https://github.com/bcherny/json-schema-to-typescript lib, but it return trashed types in some places like: export type Message =
| Reference
| (
| {
oneOf: Message[];
}
| {
schemaFormat?: string;
contentType?: string;
headers?: Schema & {
type?: {
[k: string]: unknown;
};
[k: string]: unknown;
};
payload?: unknown;
correlationId?: Reference | CorrelationId;
tags?: Tag[];
/**
* A brief summary of the message.
*/
summary?: string;
/**
* Name of the message.
*/
name?: string;
/**
* A human-friendly title for the message.
*/
title?: string;
/**
* A longer description of the message. CommonMark is allowed.
*/
description?: string;
externalDocs?: ExternalDocs;
deprecated?: boolean;
examples?: {
[k: string]: unknown;
}[];
bindings?: BindingsObject;
traits?: (
| Reference
| MessageTrait
| []
| [Reference | MessageTrait]
| [
Reference | MessageTrait,
{
[k: string]: unknown;
}
]
)[];
[k: string]: SpecificationExtension;
}
); Also https://app.quicktype.io/ has also a problem with generating types. So I decided to write types from scratch and at the moment I have a full spec written in TS, without Bindings. @derberg @fmvilas @jonaslagoni What do you think guys? |
Isn't this issue regarding missing types package for the parser itself? (not the spec) I added types for the generator, which was done with JSDoc to automatically generate the types, thinks that's the way to do here as well 😄 Think I used https://www.npmjs.com/package/tsd-jsdoc |
@jonaslagoni Yes, this issue is related to parser, but I wonder if an idea with a separate package with only types would be a good one. |
@magicmatatjahu I am unsure of the use-case specifically in this context. Are you talking about making a repository containing types from the spec it self and use that to somehow solve this issue? 🤔 Cause with tsd-jsdoc we can have 0 maintaining from our side and generate it with github actions, which I think would be perfect fit which requires a minimal effort to solve from the maintainer point of view 😄 |
I think tsd-jsdoc is the better solution here as will be published and up to date with each release of this package. The @types namespace on npm i think was originally intended to give typescript more appeal when i was originally launched as no packages had types defined and waiting for the original authors to react would be too slow. Is tsd-jsdoc something you will be publishing with this tool any time soon @jonaslagoni ? |
@johndcarmichael unless @magicmatatjahu wants to take it for a spin. As long as there are no complications with the current jsdoc implementation it shouldn't take long 😄 |
@jonaslagoni I don't have any objections with using |
@johndcarmichael PR is up, are you up for reviewing it and ensure it works as you would expect 😄? |
🎉 This issue has been resolved in version 0.28.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Awesome! Thanks for the types guys, will work the new parser into boats and delete the ignore lints and custom unique opid checks 👍 |
When using this tool programmatically within a typescript app, I could not see any type definitions anywhere.. are there any in the pipelines or an @types package i might have missed?
The text was updated successfully, but these errors were encountered: