compiler: add built-in Object.prototype methods to ShapeRegistry
This PR enhances the ShapeRegistry by incorporating additional Object.prototype methods from the TODO.
In this implementation:
-
toLocaleStringis similar to the existingtoStringmethod: it takes no arguments and returns a primitive value (string). -
hasOwnProperty,isPrototypeOf, andpropertyIsEnumerableall take one argument and return a primitive (boolean). -
valueOftakes no arguments and returns a poly type(thethisvalue, converted to an object.).
References:
- toLocaleString: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
- hasOwnProperty: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
- isPrototypeOf: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
- propertyIsEnumerable: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
- valueOf: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-compiler-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 30, 2024 6:56am |
Comparing: 7baae65e767726e44a23c13203c05ae0d540e26f...20740de620736abd7dbf8c348019a8d451376221
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| oss-stable/react-dom/cjs/react-dom.production.js | = | 6.68 kB | 6.68 kB | = | 1.83 kB | 1.83 kB |
| oss-stable/react-dom/cjs/react-dom-client.production.js | = | 497.93 kB | 497.93 kB | = | 89.26 kB | 89.26 kB |
| oss-experimental/react-dom/cjs/react-dom.production.js | = | 6.69 kB | 6.69 kB | = | 1.83 kB | 1.83 kB |
| oss-experimental/react-dom/cjs/react-dom-client.production.js | = | 502.75 kB | 502.75 kB | = | 89.96 kB | 89.96 kB |
| facebook-www/ReactDOM-prod.classic.js | = | 597.10 kB | 597.10 kB | = | 105.31 kB | 105.31 kB |
| facebook-www/ReactDOM-prod.modern.js | = | 571.44 kB | 571.44 kB | = | 101.24 kB | 101.24 kB |
| test_utils/ReactAllWarnings.js | Deleted | 62.88 kB | 0.00 kB | Deleted | 15.69 kB | 0.00 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| test_utils/ReactAllWarnings.js | Deleted | 62.88 kB | 0.00 kB | Deleted | 15.69 kB | 0.00 kB |
Generated by :no_entry_sign: dangerJS against 20740de620736abd7dbf8c348019a8d451376221
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
Oops, we missed this. I’ll review properly tomorrow
Hello @josephsavona, I was wondering if you had a chance to have a look at this PR 👀..
@josephsavona I'm getting this:
4 | const x = {
5 | valueOf() {
> 6 | return this;
| ^^^^ Todo: (BuildHIR::lowerExpression) Handle ThisExpression expressions (6:6)
7 | }
8 | };
9 | x.valueOf().y = true;
Is this error expected?
If so, may I just document it like here?: https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/error.todo-object-expression-set-syntax.expect.md#error
Hello @josephsavona , I added the fixture as stated above and would appreciate your review! Thanks!
@josephsavona This PR is ready for review! Thanks for your time 🙂
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!