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

Refactor to TypeScript #81

Open
lundberg opened this issue Mar 25, 2022 · 3 comments
Open

Refactor to TypeScript #81

lundberg opened this issue Mar 25, 2022 · 3 comments

Comments

@lundberg
Copy link
Contributor

No description provided.

@hbystrom91
Copy link
Contributor

hbystrom91 commented Mar 25, 2022

I think this would be really nice. However, it would probably mean we refactor everything to use modern React (17-18) patterns like hooks and lazy imports. Quite a big investment time-wise since we are at a pretty stable point in Bananas as of now. A complete refactor would surely introduce a lot of bugs.

A slightly less time demanding option would be to have all new features be written in TypeScript. We would probably need to update/modify our Webpack setup for it to handle .ts/tsx files but that would probably be pretty quick and easy.

The quickest option to make Bananas more TS-friendly would be to make a PR to https://github.com/DefinitelyTyped/DefinitelyTyped and have them publish @types/django-bananas.js to npm. The typings of everything that Bananas exposes would in that case be accessible for anyone using TS through that package. The downside is of course that the code base itself wouldn't be TS at all 👎

@eliassjogreen
Copy link

As @hbystrom91 suggested I have made some very loose typings in DefinitelyTyped/DefinitelyTyped#60784 for DefinatelyTyped which is waiting for review currently....

@eliassjogreen
Copy link

This issue is partly solved now by the @types/django-bananas npm package. While it works, it is somewhat untyped still (lots of any and certain external types were not linked due to some issues with compatibility between typescript/javascript module resolver types). I tried to match the code and the previously written types in mestergruppen admin as best I could but it is very possible I missed some weird JS properties which were not directly mentioned in code (for example in swagger-client which is untyped and extended by our APIClient) .

Ideally I would like to refactor everything and gradually move over to typescript fully (especially re-write the ApiClient) but that is way out of scope so for now the DefinitelyTyped types will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants