openedx / frontend-platform

A framework for Open edX micro-frontend applications.
http://openedx.github.io/frontend-platform
GNU Affero General Public License v3.0
32 stars 64 forks source link

Static Typing with TypeScript (WIP) #619

Closed bradenmacdonald closed 5 months ago

bradenmacdonald commented 11 months ago

Description:

This PR incrementally brings static typing and type checking (TypeScript) to frontend-platform. See OEP-67-8 TypeScript for some rationale.

To achieve this:

This should be 100% compatible with existing MFEs that are using this, though they might start seeing type errors if they are using typescript and have some actual errors.

This is also compatible with projects that want to use "moduleResolution": "Node16", "module": "Node16" in their tsconfig.json, i.e. use the exports key of package.json instead of the legacy approach. You can test this by putting "type": "module" in your MFE's package.json and "moduleResolution": "Node16", "module": "Node16" into tsconfig.json compilerOptions. However, most MFEs seem to be using the legacy CJS approach.

TODO:

Examples from an MFE

These screenshots are from the Course Authoring MFE. You can see that before this PR, VS Code is not aware of the type information of any of the frontend-platform functionality. (How do you live like this? :p )

Before After
Screenshot 2023-12-15 at 1 30 00 PM
intl and config are both any
Screenshot 2023-12-15 at 1 29 14 PM
Notice the types of both intl and config are now correct.
Screenshot 2023-12-15 at 1 33 13 PM Screenshot 2023-12-15 at 1 32 41 PM

Merge checklist:

Post merge:

openedx-webhooks commented 11 months ago

Thanks for the pull request, @bradenmacdonald! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

This is currently a draft pull request. When it is ready for our review and all tests are green, click "Ready for Review", or remove "WIP" from the title, as appropriate.

mphilbrick211 commented 7 months ago

Hi @bradenmacdonald! Just checking in on this to see if you're still working on it?

bradenmacdonald commented 7 months ago

@mphilbrick211 I ran into some issues and kind of lost the momentum here. I'm going to mark as a draft for now and not sure when I'll be able to revisit it. I would still like to move it forward at some point though.

bradenmacdonald commented 5 months ago

I'm going to close this, and open a few smaller PRs with some of the same changes.

openedx-webhooks commented 5 months ago

@bradenmacdonald Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

openedx-webhooks commented 5 months ago

@bradenmacdonald Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.