Skip to content

Commit 9d44c90

Browse files
Update TypeScript to 5.7.2 (#5128)
* Update TypeScript version and add type assertions in tests * Revert pnpm-lock.yaml * Lockfile * Lockfile? * Update typescript-eslint * Make eslint happy * fixed it without casts * ugh, use `unknown` annotation to satisfy eslin --------- Co-authored-by: Mateusz Burzyński <[email protected]>
1 parent 326a3ad commit 9d44c90

File tree

5 files changed

+391
-1287
lines changed

5 files changed

+391
-1287
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
"prettier-plugin-jsdoc": "^1.3.0",
8080
"svelte-jester": "^2.3.2",
8181
"synckit": "^0.8.5",
82-
"typescript": "^5.6.2",
83-
"typescript-eslint": "^8.0.1",
82+
"typescript": "^5.7.2",
83+
"typescript-eslint": "^8.16.0",
8484
"vue": "^3.0.11"
8585
},
8686
"husky": {

packages/xstate-inspect/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function inspect(options: ServerInspectorOptions): Inspector {
6868
};
6969

7070
server.on('connection', function connection(wsClient) {
71-
wsClient.on('message', function incoming(data, isBinary) {
71+
wsClient.on('message', function incoming(data: unknown, isBinary) {
7272
if (isBinary) {
7373
return;
7474
}

packages/xstate-react/test/useActor.test.tsx

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
assign,
1414
createActor,
1515
createMachine,
16-
raise
16+
raise,
17+
setup
1718
} from 'xstate';
1819
import { fromCallback, fromObservable, fromPromise } from 'xstate/actors';
1920
import { useActor, useSelector } from '../src/index.ts';
@@ -664,37 +665,34 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
664665
it('should be able to use a delay provided outside of React', () => {
665666
jest.useFakeTimers();
666667

667-
const machine = createMachine(
668-
{
669-
initial: 'a',
670-
states: {
671-
a: {
672-
on: {
673-
EV: 'b'
674-
}
675-
},
676-
b: {
677-
after: {
678-
myDelay: 'c'
679-
}
680-
},
681-
c: {}
668+
const machine = setup({
669+
delays: {
670+
myDelay: () => {
671+
return 300;
682672
}
683-
},
684-
{
685-
delays: {
686-
myDelay: () => {
687-
return 300;
673+
}
674+
}).createMachine({
675+
initial: 'a',
676+
states: {
677+
a: {
678+
on: {
679+
EV: 'b'
688680
}
689-
}
681+
},
682+
b: {
683+
after: {
684+
myDelay: 'c'
685+
}
686+
},
687+
c: {}
690688
}
691-
);
689+
});
692690

693691
const App = () => {
694692
const [state, send] = useActor(machine);
695693
return (
696694
<>
697-
<div data-testid="result">{state.value as string}</div>
695+
<div data-testid="result">{state.value}</div>
698696
<button onClick={() => send({ type: 'EV' })} />
699697
</>
700698
);
@@ -715,7 +713,11 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
715713
});
716714

717715
it('should not use stale data in a guard', () => {
718-
const machine = createMachine({
716+
const machine = setup({
717+
guards: {
718+
isAwesome: () => false
719+
}
720+
}).createMachine({
719721
initial: 'a',
720722
states: {
721723
a: {
@@ -740,7 +742,7 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
740742
);
741743
return (
742744
<>
743-
<div data-testid="result">{state.value as string}</div>
745+
<div data-testid="result">{state.value}</div>
744746
<button onClick={() => send({ type: 'EV' })} />
745747
</>
746748
);
@@ -784,7 +786,7 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
784786
});
785787

786788
it('child component should be able to send an event to a parent immediately in an effect', () => {
787-
const machine = createMachine({
789+
const machine = setup({}).createMachine({
788790
types: {} as {
789791
events: {
790792
type: 'FINISH';
@@ -1030,7 +1032,7 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
10301032
});
10311033

10321034
it('should execute a delayed transition of the initial state', async () => {
1033-
const machine = createMachine({
1035+
const machine = setup({}).createMachine({
10341036
initial: 'one',
10351037
states: {
10361038
one: {

packages/xstate-react/test/useSelector.test.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
StateFrom,
1212
Snapshot,
1313
TransitionSnapshot,
14-
AnyEventObject
14+
AnyEventObject,
15+
setup
1516
} from 'xstate';
1617
import {
1718
shallowEqual,
@@ -537,7 +538,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
537538

538539
return (
539540
<>
540-
{value}
541+
{value as number}
541542
<button
542543
type="button"
543544
onClick={() => forceRerender((s) => s + 1)}
@@ -647,7 +648,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
647648
});
648649

649650
it('should work with initially deferred actors spawned in lazy context', () => {
650-
const childMachine = createMachine({
651+
const childMachine = setup({}).createMachine({
651652
initial: 'one',
652653
states: {
653654
one: {
@@ -657,10 +658,11 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
657658
}
658659
});
659660

660-
const machine = createMachine({
661+
const machine = setup({
661662
types: {} as {
662663
context: { ref: ActorRefFrom<typeof childMachine> };
663-
},
664+
}
665+
}).createMachine({
664666
context: ({ spawn }) => ({
665667
ref: spawn(childMachine)
666668
}),
@@ -682,7 +684,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
682684

683685
return (
684686
<>
685-
<div data-testid="child-state">{childState.value as string}</div>
687+
<div data-testid="child-state">{childState.value}</div>
686688
<button
687689
data-testid="child-send"
688690
onClick={() => childRef.send({ type: 'NEXT' })}

0 commit comments

Comments
 (0)