Skip to content

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Oct 7, 2025

Summary

Node.js 22 enables the strip-only TypeScript loader by default, which no longer auto-wraps CommonJS exports the way Node.js 20's ts-node did. We normalize the mocha setup imports for chai-as-promised and nock, mirror that shim in the bin test harness, and swap the manifest parser from js-yaml to the native ESM yaml package so no ad-hoc interop is needed.

Testing

  • npm test (Node.js 22.19.0)
  • npm run test:bin (blocked locally by sandboxed npm link; covered in CI)

Updates import syntax in test files to be compatible with the new experimental TypeScript loader enabled by default in Node.js v22.18.0+.

Starting in v22.18.0, Node.js enables a "strip-only" mode for TypeScript files by default. This new loader is stricter and does not support certain TypeScript-specific syntax, such as `import = require()` declarations, which were previously handled by a separate transpiler.

This change caused `TypeError` and `SyntaxError` exceptions during test runs. This commit replaces the incompatible syntax with standard ES module imports to resolve the test failures.
Copy link
Contributor

Summary of Changes

Hello @taeold, 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 critical compatibility issues arising from the stricter experimental TypeScript loader introduced in Node.js v22.18.0 and later. The changes involve migrating specific import syntaxes within test files from the now-unsupported import = require() declarations to standard ES module imports. This update is essential for preventing TypeError and SyntaxError exceptions, ensuring the test suite continues to run without issues in modern Node.js environments.

Highlights

  • Node.js 22 Compatibility: Updated import syntax in test files to ensure compatibility with the new experimental TypeScript loader enabled by default in Node.js v22.18.0+.
  • Syntax Resolution: Replaced import = require() declarations with standard ES module imports to resolve TypeError and SyntaxError exceptions during test runs.
  • Test Stability: Ensured the test suite remains stable and functional under the stricter TypeScript loading rules introduced in recent Node.js versions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@taeold taeold requested a review from jhuleatt October 7, 2025 03:19
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 correctly updates the import syntax in test files to be compatible with Node.js v22, replacing TypeScript-specific import = require() and non-standard namespace imports with modern ES module syntax. The changes are consistent and well-explained. I've just noted a minor issue regarding the removal of trailing newlines in two of the test files, which is a common convention to maintain.

@taeold taeold changed the title fix(tests): update import syntax for Node.js 22 compatibility Fix Node.js 22 strip-only loader regression in mocha setup Oct 7, 2025
@taeold
Copy link
Contributor Author

taeold commented Oct 7, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 effectively addresses a regression in the mocha test setup caused by Node.js 22's new strip-only TypeScript loader. The solution to normalize CommonJS module exports for chai-as-promised and nock is robust, ensuring compatibility across different Node.js versions and loaders without broad configuration changes. The accompanying updates to sinon imports in test files are also correct. The changes are well-implemented and I have no suggestions for improvement.

@taeold
Copy link
Contributor Author

taeold commented Oct 7, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 addresses a regression with the TypeScript loader in Node.js 22 by normalizing CommonJS module imports for chai-as-promised and nock. It also modernizes the codebase by replacing js-yaml with the ESM-native yaml package and updating sinon imports to use ES module syntax.

The changes are well-targeted and address the compatibility issue effectively. I've made one suggestion in mocha/setup.ts to improve the consistency and readability of the import shims, making them easier to understand and maintain. Overall, this is a solid improvement.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jhuleatt jhuleatt linked an issue Oct 7, 2025 that may be closed by this pull request
@taeold taeold enabled auto-merge October 7, 2025 15:23
Copy link
Contributor

@jhuleatt jhuleatt left a comment

Choose a reason for hiding this comment

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

Interesting! I hadn't realized type stripping was enabled by default

@taeold taeold added this pull request to the merge queue Oct 7, 2025
Merged via the queue into master with commit 94fd766 Oct 7, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI is failing
2 participants