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

Validate existing JavaScript implementation with TypeScript #649

Merged
merged 47 commits into from
Dec 14, 2023
Merged

Validate existing JavaScript implementation with TypeScript #649

merged 47 commits into from
Dec 14, 2023

Conversation

EzraBrooks
Copy link
Contributor

@EzraBrooks EzraBrooks commented Nov 16, 2023

Public API Changes

  • The internals of some class constructors no longer protect against users passing undefined or no argument for options. However, this was never actually supported, so this should not affect the great majority of users.

Description

Using the TypeScript compiler to statically type-check the existing JavaScript in this repository (and hopefully also auto-generate some typescript typings, that would be nice)

TODO:

  • get it building without errors
  • add the typescript step to the grunt build
  • Tweak some build settings, probably, to reduce compiled size (removing unnecessary polyfills)

@EzraBrooks
Copy link
Contributor Author

Refactored prototypes to classes in 98ab37c due to TypeScript lacking support for JSDoc @extends for prototypes.

@EzraBrooks

This comment was marked as resolved.

@EzraBrooks

This comment was marked as resolved.

@EzraBrooks

This comment was marked as resolved.

@EzraBrooks
Copy link
Contributor Author

EzraBrooks commented Nov 17, 2023

The tsc build is passing! I had to scatter more ts-expect-error directives around than I would've liked, but that's why it's there - to allow slow conversion from untyped to typed code.

@EzraBrooks

This comment was marked as outdated.

@EzraBrooks
Copy link
Contributor Author

When reviewing this I highly recommend checking the "hide whitespace" box because there's a ton of indentation changes because of the prototype->class migration.

@EzraBrooks

This comment was marked as resolved.

@EzraBrooks

This comment was marked as resolved.

@EzraBrooks
Copy link
Contributor Author

I've been progressively rolling back any "fixes" that I made in the name of making red squiggles go away, in favor of instead marking them with // @ts-expect-error so we can have the build pass but have a to-do list of fixes to make by just searching for that marker in the codebase.

This PR is a substantial enough improvement just from having syntactically-correct JSDoc that is validated by tsc and having ES6+ classes.

@EzraBrooks EzraBrooks marked this pull request as draft November 27, 2023 22:34
@EzraBrooks
Copy link
Contributor Author

getting very close but still wrestling with some JSDoc details.

@MatthijsBurgh MatthijsBurgh added the v2 Issues and PRs, which will be fixed in v2, as it is a breaking change label Nov 28, 2023
@EzraBrooks
Copy link
Contributor Author

I've been playing with the typescript compiler settings and I don't think I can make the bundle smaller, if we're going to continue supporting ES5 (which I think we should for now).

In my opinion we should take the size hit, then switch to a more optimal bundler that may help, then over time incrementally raise our target ECMAScript version to reduce the number of polyfills TypeScript is including.

not sure why they didn't work before
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got to a point where these changes work in our dev environment, so I'm approving this.

Of course, let's cut this v1/v2 boundary first before merging here.

@EzraBrooks EzraBrooks marked this pull request as ready for review November 28, 2023 20:19
@EzraBrooks
Copy link
Contributor Author

I think we should get rid of the built content in the repo a la #643 before merging this - but yeah, need v2 cut.

@EzraBrooks
Copy link
Contributor Author

consensus between me and @sea-bass: this is:

  • a release delineating change
  • too big to review well
  • and I really did try pretty damn hard not to break API which was quite difficult

so we're gonna merge this and fix any other problems as they arise in our usage or in Issues.

@EzraBrooks EzraBrooks changed the title Add typescript Validate existing JavaScript implementation with TypeScript Dec 14, 2023
@sea-bass
Copy link
Contributor

We also are actively using this branch in our project, so that gives us confidence that it does, in fact, work.

@EzraBrooks EzraBrooks merged commit eda1226 into RobotWebTools:develop Dec 14, 2023
3 checks passed
@MatthijsBurgh
Copy link
Contributor

Why are we bumping to 1.4.1? Why not already bump it to 2.0.0, so people know this isn't 1.X anymore. Doesn't mean we need to release it.

@MatthijsBurgh
Copy link
Contributor

Or this isn't breaking yet?

@sea-bass
Copy link
Contributor

Why are we bumping to 1.4.1? Why not already bump it to 2.0.0, so people know this isn't 1.X anymore. Doesn't mean we need to release it.

We probably should bump it to 2.0.0. I can do it in #645, or we can do it as a standalone PR.

@EzraBrooks
Copy link
Contributor Author

this shouldn't be breaking yet - but anyway, sorry, the 1.4.1 came in as a merge conflict and I should've reconciled it as 2.0.0!

@EzraBrooks EzraBrooks added this to the 2.0.0 milestone Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Issues and PRs, which will be fixed in v2, as it is a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants