Conversation
`'a' instanceof String => false` and `true instanceof Boolean => false`, the capitalized versions of JavaScript primitive types are avoided because they lead us to think that we're dealing with actual instances of those classes, when we're most often not (as in our case).
In TypeScript, we avoid the usage of `Object`, favoring `object` instead. Also, we use `void` as the return type of functions that return `undefined`, this indicates that we don't really care that it outputs `undefined`, it is `void`, which means that it's nothing and the return of it should be ignored.
By casting `'overflowX'|'overflowY'` to the `overflowProperty`, we tell the compiler (or type checker) which property we'll be accesing from the `CSSStyleDeclaration`. That's useful for IDEs such as VSCode, that uses the TypeScript parser to analyze the code. It can also be useful if we decide to add a type checker to the codebase later on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, I was reading the source code to better understand how the smooth scroll works and how one would polyfill it. I found myself making some comments to better understand the code and I thought it could be a small contribution for future developers also trying to understand it.
This PR:
prettierto its latest versionAll changes are cosmetic and I totally understand if you decide not to merge this PR since it's not addressing any existing issues.
Thanks for the good code, I've learned a lot!