Skip to content

Commit

Permalink
Update TypeScript to 5.7.2 (#5128)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
davidkpiano and Andarist authored Nov 29, 2024
1 parent 326a3ad commit 9d44c90
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 1,287 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"prettier-plugin-jsdoc": "^1.3.0",
"svelte-jester": "^2.3.2",
"synckit": "^0.8.5",
"typescript": "^5.6.2",
"typescript-eslint": "^8.0.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.16.0",
"vue": "^3.0.11"
},
"husky": {
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-inspect/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function inspect(options: ServerInspectorOptions): Inspector {
};

server.on('connection', function connection(wsClient) {
wsClient.on('message', function incoming(data, isBinary) {
wsClient.on('message', function incoming(data: unknown, isBinary) {
if (isBinary) {
return;
}
Expand Down
58 changes: 30 additions & 28 deletions packages/xstate-react/test/useActor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
assign,
createActor,
createMachine,
raise
raise,
setup
} from 'xstate';
import { fromCallback, fromObservable, fromPromise } from 'xstate/actors';
import { useActor, useSelector } from '../src/index.ts';
Expand Down Expand Up @@ -664,37 +665,34 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
it('should be able to use a delay provided outside of React', () => {
jest.useFakeTimers();

const machine = createMachine(
{
initial: 'a',
states: {
a: {
on: {
EV: 'b'
}
},
b: {
after: {
myDelay: 'c'
}
},
c: {}
const machine = setup({
delays: {
myDelay: () => {
return 300;
}
},
{
delays: {
myDelay: () => {
return 300;
}
}).createMachine({
initial: 'a',
states: {
a: {
on: {
EV: 'b'
}
}
},
b: {
after: {
myDelay: 'c'
}
},
c: {}
}
);
});

const App = () => {
const [state, send] = useActor(machine);
return (
<>
<div data-testid="result">{state.value as string}</div>
<div data-testid="result">{state.value}</div>
<button onClick={() => send({ type: 'EV' })} />
</>
);
Expand All @@ -715,7 +713,11 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
});

it('should not use stale data in a guard', () => {
const machine = createMachine({
const machine = setup({
guards: {
isAwesome: () => false
}
}).createMachine({
initial: 'a',
states: {
a: {
Expand All @@ -740,7 +742,7 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
);
return (
<>
<div data-testid="result">{state.value as string}</div>
<div data-testid="result">{state.value}</div>
<button onClick={() => send({ type: 'EV' })} />
</>
);
Expand Down Expand Up @@ -784,7 +786,7 @@ describeEachReactMode('useActor (%s)', ({ suiteKey, render }) => {
});

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

it('should execute a delayed transition of the initial state', async () => {
const machine = createMachine({
const machine = setup({}).createMachine({
initial: 'one',
states: {
one: {
Expand Down
14 changes: 8 additions & 6 deletions packages/xstate-react/test/useSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
StateFrom,
Snapshot,
TransitionSnapshot,
AnyEventObject
AnyEventObject,
setup
} from 'xstate';
import {
shallowEqual,
Expand Down Expand Up @@ -537,7 +538,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {

return (
<>
{value}
{value as number}
<button
type="button"
onClick={() => forceRerender((s) => s + 1)}
Expand Down Expand Up @@ -647,7 +648,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
});

it('should work with initially deferred actors spawned in lazy context', () => {
const childMachine = createMachine({
const childMachine = setup({}).createMachine({
initial: 'one',
states: {
one: {
Expand All @@ -657,10 +658,11 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {
}
});

const machine = createMachine({
const machine = setup({
types: {} as {
context: { ref: ActorRefFrom<typeof childMachine> };
},
}
}).createMachine({
context: ({ spawn }) => ({
ref: spawn(childMachine)
}),
Expand All @@ -682,7 +684,7 @@ describeEachReactMode('useSelector (%s)', ({ suiteKey, render }) => {

return (
<>
<div data-testid="child-state">{childState.value as string}</div>
<div data-testid="child-state">{childState.value}</div>
<button
data-testid="child-send"
onClick={() => childRef.send({ type: 'NEXT' })}
Expand Down
Loading

0 comments on commit 9d44c90

Please sign in to comment.