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

types: Migrated todo_widget.js to todo_widget.ts. #29243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wr4th100
Copy link
Contributor

@Wr4th100 Wr4th100 commented Mar 8, 2024

  • Migrated todo_widget.js to Typescript for improved type safety and maintainability.
  • Renamed the file in tests-js-with-node.
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.

web/src/todo_widget.ts Outdated Show resolved Hide resolved
@Wr4th100 Wr4th100 force-pushed the Wr4th100/todo_widget branch 2 times, most recently from df063b1 to 775c46d Compare March 9, 2024 10:11
@andersk andersk added the area: typescript migration Issues for migrating Zulip to TypeScript label Mar 19, 2024
@timabbott
Copy link
Sponsor Member

This feels very hard to review; git show doesn't even think it's the same file. It looks like you've got a lot of new logic to condition on undefined situations that are not real scenarios; like this:

+            const taskValue = $elem?.find("input.add-task")?.val();
+            const task = (typeof taskValue === "string" ? taskValue : "").trim();
+            const descValue = $elem?.find("input.add-desc")?.val();
+            const desc = (typeof descValue === "string" ? descValue : "").trim();

These should largely be done via adding assert statements or !s, not creating new impossible scenarios involving using "" as a value if something we think impossible happens.

You also seem to have re-sorted the functions. Please don't do that in a TS migration commit; if you need to do it, do it in an easily reviewed function either before or after.

@Wr4th100 can you rework this to be more reviewable?

@Wr4th100
Copy link
Contributor Author

You also seem to have re-sorted the functions. Please don't do that in a TS migration commit; if you need to do it, do it in an easily reviewed function either before or after.

I changed the order, because eslint was complaining about it (@typescript-eslint/member-ordering). I have disabled the eslint check now. git now recognizes it as the same file.

These should largely be done via adding assert statements or !s, not creating new impossible scenarios involving using "" as a value if something we think impossible happens.

Sure, I have made the changes now, please have a look!

@Wr4th100 Wr4th100 closed this Mar 24, 2024
@Wr4th100 Wr4th100 reopened this Mar 24, 2024
@Wr4th100 Wr4th100 force-pushed the Wr4th100/todo_widget branch 2 times, most recently from 5c383cc to 5de10f4 Compare March 27, 2024 13:51
@Wr4th100
Copy link
Contributor Author

@timabbott, I have made the necessary changes, and all the checks have passed, please have a look!

@LaPulgaaa
Copy link
Contributor

LaPulgaaa commented Apr 21, 2024

@Wr4th100 Can you provide an update on this migration? This surely requires a rebase if anything. It would be nice to get this migrated!

@@ -39,59 +114,59 @@ export class TaskData {
}

for (const [i, data] of tasks.entries()) {
this.handle.new_task.inbound("canned", {
this.handle.new_task.inbound(message_sender_id, {
key: i,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally, the inbound function receives the sender_id argument as number. But here, they have mentioned canned here. I have changed that to message_sender_id.

Is this correct? Or should I be changing something else?

Copy link
Collaborator

@afeefuddin afeefuddin May 6, 2024

Choose a reason for hiding this comment

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

Change the type annotations of the parameter of the inbound function to accept string | number, otherwise, it might result in a key error. You can read the CZO thread for more context.

Copy link
Collaborator

@afeefuddin afeefuddin May 6, 2024

Choose a reason for hiding this comment

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

Also, when making these types of changes, it's recommended to create a separate commit and provide a valid reason for why you chose that approach.

@afeefuddin
Copy link
Collaborator

Hey @Wr4th100, are you looking forward to completing this one?

Migrated todo_widget.js to todo_widget.ts for enhanced type-safety.
Changed the file name in tools/test-js-with-node.
@Wr4th100 Wr4th100 reopened this May 11, 2024
@timabbott
Copy link
Sponsor Member

@Wr4th100 can you comment on how you resolved the feedback? I guess @N-Shar-ma should probably review this in any case.

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