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

ts: Convert emoji.js to TypeScript. #24875

Merged
merged 2 commits into from Apr 5, 2023
Merged

Conversation

Lalit3716
Copy link
Collaborator

@Lalit3716 Lalit3716 commented Mar 26, 2023

Converted emoji.js to TypeScript by adding relevant type definitions, also modified target option in our tsconfig to 'ES2022' so that types for object methods like hasOwn which is being used in emoji.js are included.

Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@PIG208
Copy link
Member

PIG208 commented Mar 26, 2023

diff --git a/.eslintrc.json b/.eslintrc.json
index c3cabcdac5..b126a19af3 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -140,6 +140,8 @@
         {
             "files": ["web/src/**"],
             "globals": {
+                "Iterator": true,
+                "IterableIterator": true,
                 "StripeCheckout": false
             }
         },

Adding Iterator and IterableIterator to .eslintrc.json should fix the issue.

@Lalit3716 Lalit3716 force-pushed the emoji-ts branch 3 times, most recently from dd7464f to ee60e70 Compare March 27, 2023 13:27
@Lalit3716
Copy link
Collaborator Author

Yep that fixed it thanks @PIG208 !

@andersk
Copy link
Member

andersk commented Mar 27, 2023

This seems to be

Ideally, we don’t want to have to manually list all the ES2022 globals we use. Until that fix is merged, try using target: "ESNext" instead.

@Lalit3716
Copy link
Collaborator Author

@andersk That worked too so changed "ES2022" -> "ESNext".

web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
@Lalit3716 Lalit3716 force-pushed the emoji-ts branch 2 times, most recently from 58c96b1 to c6c7759 Compare March 29, 2023 13:44
@Lalit3716
Copy link
Collaborator Author

Removed unnecessary map export const deactivated_emoji_name_to_code = new Map();, ready for another review now!

web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
web/src/emoji.ts Outdated Show resolved Hide resolved
@timabbott
Copy link
Sponsor Member

Thanks for the work on this @Lalit3716! I posted a bunch of comments, mostly on naming -- I think my main advice is to spend more time thinking about what to call types, and if you're not sure, consider posting in #frontend to get feedback -- names are really important to the readability of code, and a big part of the benefit of moving to TypeScript is having named types for things, so it's definitely well worth our time to try to name things well. Usually there's pretty good hints in the names of the functions etc. that use a given type.

@Lalit3716
Copy link
Collaborator Author

Thanks for the review! Also I will make sure to take my time with naming things in my future work!, will update the PR soon 🙂.

This is a prep commit for typescript migration of `emoji.js`. This
commit refactors the code for generating emoji rendering details such
that we avoid writing an ugly code which will involve writing an
incomplete type object when we migrate to TypeScript.
Converted `emoji.js` to TypeScript by adding relevant type definitions,
also modified `target` option in our tsconfig to 'ESNext' so that types
for object methods like `hasOwn` which is being used in `emoji.js` are
included.
@Lalit3716
Copy link
Collaborator Author

@timabbott This is ready to review.

I have addressed all the review comments and made a prep commit for the suggested refactoring.

@timabbott timabbott merged commit bbf2f5f into zulip:main Apr 5, 2023
6 checks passed
@timabbott
Copy link
Sponsor Member

This is great, merged, thanks @Lalit3716!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: typescript migration Issues for migrating Zulip to TypeScript size: XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants