Skip to content

Conversation

@snomiao
Copy link
Member

@snomiao snomiao commented Sep 4, 2025

Summary

Remove the useDefineForClassFields compiler option from tsconfig.json to fix Playwright test configuration compatibility issues.

Changes

  • Removed useDefineForClassFields: true from tsconfig.json

Test plan

  • CI/CD tests pass
  • Playwright tests run successfully
  • Build completes without errors

🤖 Generated with Claude Code

┆Issue is synchronized with this Notion page by Unito

Remove the useDefineForClassFields compiler option from tsconfig.json
to fix Playwright test configuration compatibility issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

🎭 Playwright Test Results

All tests passed across all browsers!

⏰ Completed at: 09/04/2025, 10:35:08 PM UTC

📊 Test Reports by Browser


🎉 Your tests are passing across all browsers!

@christian-byrne
Copy link
Contributor

In the spec, it says this is set to true if the target is ES2022, which ours is.

snomiao and others added 2 commits September 4, 2025 03:40
Add sno-fix-playwright branch prefix to i18n workflow trigger conditions to allow automated locale updates during Playwright-related fixes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@socket-security
Copy link

socket-security bot commented Sep 4, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addeduuid@​11.1.010010010084100
Addedsemver@​7.7.210010010085100
Addedtypescript@​5.9.210010089100100

View full report

@snomiao
Copy link
Member Author

snomiao commented Sep 4, 2025

Analysis of i18n Playwright Test Failure

The Update Locales workflow is failing with the error:

SyntaxError: TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript

Root Cause

The i18n collection scripts (scripts/collect-i18n-*.ts) are importing TypeScript source files directly and executing them in Node.js context during Playwright tests. This bypasses the normal Vite build pipeline and instead relies on Playwright's TypeScript compilation, which uses Babel under the hood.

Why This Happens

  1. Direct imports: The i18n scripts import TypeScript modules like ../src/constants/coreMenuCommands directly
  2. Babel transformation: Playwright uses Babel to transform TypeScript, not the TypeScript compiler (tsc)
  3. Missing plugin configuration: Babel needs @babel/plugin-transform-typescript to handle declare fields, but it must run before class property plugins

The Issue with declare Fields

When useDefineForClassFields: false was removed from tsconfig.json, TypeScript now uses declare for class fields that shouldn't be initialized. However, Babel's plugin order matters - the TypeScript plugin must process declare fields before class property transformations.

Possible Solutions

  1. Configure Babel for Playwright (recommended): Add a babel config specifically for Playwright tests that ensures correct plugin order
  2. Re-add useDefineForClassFields: true: Explicitly set this in tsconfig to avoid declare fields
  3. Refactor i18n scripts: Avoid importing TypeScript source files directly, use compiled outputs instead
  4. Update Playwright's TypeScript handling: Configure Playwright to use tsc instead of Babel

The TypeScript and Playwright version updates (5.9.2 and 1.55.0) are working correctly for the main test suite - the issue is specific to how the i18n collection scripts compile TypeScript.

- Set useDefineForClassFields to true in tsconfig.json to prevent TypeScript declare field issues
- This avoids Babel transformation errors in Playwright i18n tests
- Remove explicit declare keywords from LGraphNode to fix Babel compilation
- Set useDefineForClassFields to true to handle field initialization properly
- This fixes the i18n Playwright test failures
- Remove useDefineForClassFields from tsconfig to maintain backward compatibility
- Keep explicit field declarations removed to fix i18n Playwright tests
- This balances both test suite requirements
- Remove declare keywords from all litegraph class fields
- This fixes Babel TypeScript compilation in Playwright i18n tests
- Maintains backward compatibility without useDefineForClassFields
- Add ! definite assignment assertions to properties that were using declare
- This fixes TypeScript compilation errors while maintaining Babel compatibility
- Properties are guaranteed to be assigned at runtime
@socket-security
Copy link

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
[email protected] has Obfuscated code.

Confidence: 0.94

Location: Package overview

From: pnpm-lock.yamlnpm/[email protected]npm/[email protected]

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@snomiao snomiao closed this Sep 5, 2025
@snomiao
Copy link
Member Author

snomiao commented Sep 5, 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.

3 participants