From 5e0808eb440f77b8404db6676401849053cfcfd8 Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Sat, 5 Nov 2022 15:07:48 -0400 Subject: [PATCH] Allow to disable removing the predictable action arguments warning by setting the flag to false (#3666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove predictableActionArguments warning * Add changeset * Remove warning * Modify warning * Update .changeset/silver-mayflies-speak.md Co-authored-by: Mateusz Burzyński Co-authored-by: Mateusz Burzyński --- .changeset/silver-mayflies-speak.md | 5 +++++ packages/core/src/Machine.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/silver-mayflies-speak.md diff --git a/.changeset/silver-mayflies-speak.md b/.changeset/silver-mayflies-speak.md new file mode 100644 index 0000000000..faf1943c21 --- /dev/null +++ b/.changeset/silver-mayflies-speak.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +The warning for the `predictableActionArguments` setting has been improved to only warn if it is absent. You can disable the warning by setting `predictableActionArguments: false`. It's still recommended to set it to `true` though. diff --git a/packages/core/src/Machine.ts b/packages/core/src/Machine.ts index b5eea62c6e..bfeb791a67 100644 --- a/packages/core/src/Machine.ts +++ b/packages/core/src/Machine.ts @@ -142,11 +142,12 @@ export function createMachine< TServiceMap, TTypesMeta > { - if (!IS_PRODUCTION && !config.predictableActionArguments && !warned) { + if (!IS_PRODUCTION && !('predictableActionArguments' in config) && !warned) { warned = true; console.warn( 'It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html' ); } + return new StateNode(config, options as any) as any; }