Skip to content

chore: use real private class fields (Node.js v12 was dropped)#111

Open
telleroutlook wants to merge 1 commit into
nicolo-ribaudo:mainfrom
telleroutlook:chore/todo-src-index-js-10
Open

chore: use real private class fields (Node.js v12 was dropped)#111
telleroutlook wants to merge 1 commit into
nicolo-ribaudo:mainfrom
telleroutlook:chore/todo-src-index-js-10

Conversation

@telleroutlook
Copy link
Copy Markdown

The package.json engines field now requires ^16.10.0 || ^18.12.0 || >=20.0.0, meaning Node.js 12 support was dropped long ago.

This converts the pseudo-private fields (_foo) to real ES2022 private fields (#foo) in both LightRunner and MainThreadTinypool, fulfilling the TODO comment left in the original code:

// TODO: Use real private fields when we drop support for Node.js v12

Changes:

  • LightRunner._globalConfig#globalConfig
  • LightRunner._testRunners#testRunners
  • LightRunner._runtime#runtime
  • LightRunner._runTest()#runTest()
  • MainThreadTinypool._moduleP#moduleP
  • MainThreadTinypool._worker#worker
  • MainThreadTinypool._workerData#workerData

Real private fields provide stronger encapsulation guarantees: they are enforced by the JS engine and are not accessible outside the class, unlike the _ naming convention which is purely a convention.

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.

1 participant