auro-button: add TypeScript declarations
Closed this issue · 3 comments
Is your feature request related to a problem? Please describe.
Multiple teams across E-Commerce use TypeScript and Auro. The Auro libraries do not generate typings or declaration files - therefore, we have to add types ourselves. There are many examples of repositories typing the auro components as "any".
Moving from "any" to a strongly typed auro interface will benefit all teams who use TypeScript by reducing the number of potential bugs with type-ohs. It will also speed up our workflow when we upgrade the components, because we will be able to see where contracts changed and where we need to make manual updates.
Examples of repos typing auro components with "any":
Describe the solution you'd like
Add a declarations file to the auro libraries. The types don't need to be tied to any framework (react, etc) but I would also like to update the examples of usage to show how to use those types.
How to do this -
- Add a file with the extension "d.ts" to the repository
- Make sure the new *.d.ts file is included in the build output directory
- Add a "types" reference to the package.json, with the path to the new *.d.ts file in the build output directory
- Maintain the *.d.ts file as contracts change
Describe alternatives you've considered
- Rewrite auro in typescript :D
- Maintain types outside of the auro component repositories, but this is a messier solution, as there will be multiple places to update as the contracts change, undoubtedly leading to confusion and mis-matched types
Additional context
I am happy to help! I can submit a PR with an example.
Researching this issue, generating typescript descriptions is a simple automated process we can add to any component. The big issue that we need to address is that this will not work with components where the default class is not exported, e.g. 99.999% of our current components including this one.
The only element that lives up to this new spec is auro-hyperlink. The good news is that we have a plan to update all our components to fit this model.
Scope of work
Update element to export component class by default. See the following PR for the exact work to be done.
Once completed, following these instructions install the tsc
process to generate the necessary TypeScript definition files
Exit criteria
This issue will be considered resolved once...
- the component has been updated to export the class by default
- the TypeScript generator has been installed and there is a confirmed correct output
The following issue was created to update the generator
This work can be tracked by this issue and linked commit