-
Notifications
You must be signed in to change notification settings - Fork 67
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
Generate/publish Typescript types #195
Comments
Related (at least in spirit) to elastic/kibana#38598 |
+1 on this. I would suggest to first publish it to this repo and then take it from there. Any suggestion on where in this package we could put these files? |
Publishing to this repo means adding a import * as EPR from '@elastic/package-registry'; // or whatever it's called I think As I linked in the description, there's an issue OneOfOne/struct2ts#24 that prevents completely automating the conversion. Actually, I guess we could add We could delay committing to a package name & getting the release process down for now by using |
BTW, the value of this was shown again while testing the import * as EPR from '@elastic/package-registry';
// ...
export type RegistryPackage = EPR.Package;
Sure enough, the manually maintained While the package-registry/util/dataset.go Line 18 in 3114374
The output generated by |
@ruflin I can submit a PR with the required items I mentioned in #195 (comment) if you like. The only thing I'd need to know is if you have an opinion on how to generate the types. e.g. should it be another side effect of |
I would make it part of Would be great if you can open a PR with it. |
Closing this issue as I think the OpenAPI approach replaces this. @jfsiii Please reopen if you think otherwise. |
EPM maintains TS types for the Registry API responses https://github.com/elastic/kibana/blob/0393fea11c57713f6a9523ef463ff03decb912d2/x-pack/legacy/plugins/epm/common/types.ts#L41-L61 but it requires an individual to watch the Registry commits and be sure to update them on the EPM side. This is burdensome and unreliable. See elastic/kibana#52285 which added several properties which were missing entirely and marked others as optional which had been marked as required.
Perhaps EPR could generate TS types as part of a build/release process like it does with the JSON docs from #14
There are a few projects which do this sort of thing. Some I found are
I tried
struct2ts
and pointed it at theutil.Package
struct and it produced something quite useful (although there was one issue with the output)There are several options/decisions here (how to convert: use CLI to point at a file/directory or use golang lib to convert a list and write files ourselves? how to share: publish as local to this package or to https://github.com/DefinitelyTyped/DefinitelyTyped, etc) but I think there's a lot of value here for relatively low effort, IMO.
The text was updated successfully, but these errors were encountered: