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

runtime(js): fix useOptionalChain #1861

Merged
merged 1 commit into from
Mar 11, 2025
Merged

runtime(js): fix useOptionalChain #1861

merged 1 commit into from
Mar 11, 2025

Conversation

smorimoto
Copy link
Member

It's already widely used in the runtime and can be unlocked since it's already included in the ECMASCRIPT documentation.

@smorimoto smorimoto requested review from hhugo and Copilot March 9, 2025 10:30

Choose a reason for hiding this comment

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

PR Overview

This pull request updates the codebase to use ECMAScript optional chaining for cleaner, more concise property and method access.

  • Replaces several conditional property checks (e.g. "x && x.prop") with optional chaining (e.g. "x?.prop").
  • Applies the optional chaining update consistently across multiple runtime files, improving code readability.

Reviewed Changes

File Description
runtime/js/dynlink.js Applies optional chaining for symbol lookup in the dynamic linker.
runtime/js/fs_fake.js Uses optional chaining when extracting parent directory from regex match.
runtime/js/obj.js Replaces traditional checks with optional chaining in custom type tests.
runtime/js/sys.js Uses optional chaining for process and child process properties.
runtime/js/jslib.js Updates loops to use optional chaining for trampoline execution.
runtime/js/fs.js Applies optional chaining when matching drive roots.
runtime/js/hash.js Uses optional chaining in custom hash computation functions.
runtime/js/effect.js Replaces loop condition checks with optional chaining.
runtime/js/compare.js Uses optional chaining for custom comparison functions.
runtime/wasm/runtime.js Applies optional chaining for process event handler setup.

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Signed-off-by: Sora Morimoto <sora@morimoto.io>
@smorimoto smorimoto force-pushed the fix-useOptionalChain branch from 7f891d2 to 5648dc7 Compare March 11, 2025 11:06
@hhugo hhugo merged commit ac2affe into master Mar 11, 2025
30 checks passed
@hhugo hhugo deleted the fix-useOptionalChain branch March 11, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants