-
Notifications
You must be signed in to change notification settings - Fork 115
Update tsconfig.json target to "es2021" and module to "esnext" #5839
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
Conversation
Summary of ChangesHello @juliawu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses necessary adjustments to the codebase following an upgrade of the TypeScript compilation target to Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the way i18n JSON files are imported, switching from dynamic import() to require(). This change is applied consistently across numerous files and is a consequence of upgrading the TypeScript target to es2021 in tsconfig.json. The related adjustment in i18n.tsx to handle both module formats is also correct.
My main feedback is a suggestion to improve type safety. The switch to synchronous require() calls causes a mismatch with the loadLocaleData function's type signature, which expects an array of Promises. I've left a specific comment with a recommendation to update the function signature to align with its new usage.
| .then((messages) => { | ||
| for (const msg of messages) { | ||
| Object.assign(allMessages, msg.default); | ||
| Object.assign(allMessages, msg.default || msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this change correctly handles modules loaded via require, the calls to loadLocaleData throughout the codebase now pass synchronous require() results, which are not Promises. This violates the function's type signature for the modules parameter (Promise<Record<any, any>>[]).
To maintain type safety, please update the signature of loadLocaleData to reflect its new usage. For example:
function loadLocaleData(
locale: string,
modules: (Promise<Record<any, any>> | Record<any, any>)[]
): Promise<void> {This will ensure the function signature accurately represents that it can handle both promises (from dynamic import()) and direct objects (from require()).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
static/js/i18n/i18n.tsx
Outdated
| function loadLocaleData( | ||
| locale: string, | ||
| modules: Promise<Record<any, any>>[] | ||
| modules: Promise<Record<string, any>>[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to double check, we don't pass other types other than string to modules in Record's first arg right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, as far as I'm aware, we only use string.
static/js/shared/util.ts
Outdated
| import axios from "axios"; | ||
| import _ from "lodash"; | ||
| import { URLSearchParams } from "url"; | ||
| // import { URLSearchParams } from "url"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not in use, can we remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Thanks for the catch. I was trying to do some edits via JetSki/Antigravity and it looks like this particular change didn't sync. Removed.
shixiao-coder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, just a few comments
As part of #5835 , the target in tsconfig.json needs to be upgraded from es6 to es2021. This PR isolates the es2021 change.
The main difference appears to be how dynamic imports are treated. This PR:
import()as we have across the codebaseloadLocaleData()) to be es2021 compatible