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

infra: modernize and improve rigor/safety of ferris.js #3937

Merged
merged 1 commit into from
May 22, 2024

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented May 22, 2024

  • Use let instead of var throughout. All modern browsers support it and have for many years, even the now-EOL IE11.1
  • Add a @ts-check annotation so that anyone working on a TS-enabled editor will get feedback inline about cases they may otherwise miss.
  • Add JSDoc-based type definitions for the script, and fix some errors that may occur at runtime. (These will be rare if they happen, but getting rid of them is still a win!)
screenshots to show it still works

CleanShot 2024-05-22 at 15 48 22@2x
CleanShot 2024-05-22 at 15 48 11@2x

Footnotes

  1. IE11 did not correctly support the semantics of let for for loops, but the uses in the existing code here already used var in a way which would trigger the same behavior as using let does.

- Use `let` instead of `var` throughout. All modern browsers support it
  and have for many years, even the now-EOL IE11.[^ie]
- Add a `@ts-check` annotation so that anyone working on a TS-enabled
  editor will get feedback inline about cases they may otherwise miss.
- Add JSDoc-based type definitions for the script, and fix some errors
  that may occur at runtime. (These will be rare if they happen, but
  getting rid of them is still a win!)

[^ie]: IE11 did not correctly support the semantics of `let` for `for`
    loops, but the uses in the existing code here already used `var` in
    a way which would trigger the same behavior as using `let` does.
@@ -1,4 +1,11 @@
var ferrisTypes = [
// @ts-check
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this does not require folks to have or use TS to contribute to this; it just enables inline feedback when working on the file for people who do use editors which integrate TS, or for folks who opt into it.

@chriskrycho chriskrycho merged commit 5c8d7df into main May 22, 2024
6 checks passed
@chriskrycho chriskrycho deleted the ferris-js-updates branch May 22, 2024 21:50
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

Successfully merging this pull request may close these issues.

None yet

1 participant