@samitouri / QOS-React-1 / commits / 369c315ac4

[hir] Update error message to say global

This is non ideal but at least it's a step in the right direction. Getting the correct error requires us to track every identifier and global, which seems a bit excessive for now. We can revisit and improve this error if this is starting to confuse folks.

Sathya Gunasekaran committed Nov 15, 2023 at 17:03 UTC 369c315ac49806f5869ec3754cbd9747fe72993d
11 files changed +12 -12
compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts
+2 -2
@@ -353,7 +353,7 @@ class InferenceState {
353 effect = Effect.Mutate;
354 } else {
355 CompilerError.throwInvalidReact({
356 - reason: `This mutates a variable after it was passed to React, which means that React cannot observe changes to it`,
356 + reason: `This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it`,
357 description:
358 place.identifier.name !== null
359 ? `Found mutation of ${place.identifier.name}`
@@ -370,7 +370,7 @@ class InferenceState {
370 valueKind !== ValueKind.Context
371 ) {
372 CompilerError.throwInvalidReact({
373 - reason: `This mutates a variable after it was passed to React, which means that React cannot observe changes to it`,
373 + reason: `This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it`,
374 description:
375 place.identifier.name !== null
376 ? `Found mutation of ${place.identifier.name}`
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md
+1 -1
@@ -15,7 +15,7 @@ function Component(props) {
15 ## Error
16
17 ```
18 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
18 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
19 ```
20
21
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md
+1 -1
@@ -16,7 +16,7 @@ function Component(props) {
16 ## Error
17
18 ```
19 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
19 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
20 ```
21
22
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md
+1 -1
@@ -16,7 +16,7 @@ function Component(props) {
16 ## Error
17
18 ```
19 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
19 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
20 ```
21
22
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md
+1 -1
@@ -16,7 +16,7 @@ function Component(props) {
16 ## Error
17
18 ```
19 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
19 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
20 ```
21
22
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component(props) {
18 ## Error
19
20 ```
21 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
21 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
22 ```
23
24
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md
+1 -1
@@ -25,7 +25,7 @@ function Component(props) {
25 ## Error
26
27 ```
28 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (13:13)
28 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (13:13)
29 ```
30
31
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md
+1 -1
@@ -19,7 +19,7 @@ function Component(props) {
19 ## Error
20
21 ```
22 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (7:7)
22 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (7:7)
23 ```
24
25
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md
+1 -1
@@ -16,7 +16,7 @@ function Component(props) {
16 ## Error
17
18 ```
19 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
19 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
20 ```
21
22
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md
+1 -1
@@ -15,7 +15,7 @@ function Foo() {
15 ## Error
16
17 ```
18 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
18 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
19 ```
20
21
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md
+1 -1
@@ -15,7 +15,7 @@ function Foo() {
15 ## Error
16
17 ```
18 -[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
18 +[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
19 ```
20
21
\ No newline at end of file