Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

TypeScript private class fields (#privateProperty) weren't being transpiled, causing runtime errors in Lynx's ES2019-based JavaScript engine.

Changes

  • SWC Configuration: Added target: 'es2019' to global SWC config to transpile private fields to WeakMap-based implementation
  • Test Coverage: Added test verifying private fields transpile correctly (no # syntax in output, WeakMap pattern present)
  • Demo: Updated example app to demonstrate private property usage

Technical Details

Without an explicit target, SWC defaults to modern ES output, leaving private field syntax unchanged:

// Input
class Demo {
  #private: string;
  getPrivate() { return this.#private; }
}

// Before: Output for Lynx runtime (unsupported)
class Demo {
  #private;  // Runtime error: unsupported syntax
}

// After: Output for Lynx runtime (ES2019 compatible)
var _private = new WeakMap();
class Demo {
  constructor() { _private.set(this, void 0); }
  getPrivate() { return _private.get(this); }
}

The main thread layer already set this target explicitly, but the background (Lynx runtime) layer inherited global config without a target.

Original prompt

在 @lynx-family/lynx-stack/files/examples/react/src/App.tsx 创建一个带有私有属性(#privateProperty)的demo类并测试使用,然后运行时引擎会报错并不支持,因此希望你看看为啥。


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 13, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: 88f0614

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Add demo class with private property in App.tsx Fix: Transpile private class fields for ES2019 runtime compatibility Nov 13, 2025
Copilot AI requested a review from hzy November 13, 2025 09:31
Copilot finished work on behalf of hzy November 13, 2025 09:31
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.

2 participants