Skip to content

Commit

Permalink
Fixed the declared signature of one of the StateMachine's methods t…
Browse files Browse the repository at this point in the history
…o avoid using a private name `this`
  • Loading branch information
Andarist committed Jun 8, 2022
1 parent a990f0e commit 1dcf74b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-carrots-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

Fixed the declared signature of one of the `StateMachine`'s methods to avoid using a private name `this`. This makes it possible to emit correct `.d.ts` for the associated file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@changesets/cli": "^2.19.0",
"@manypkg/cli": "^0.16.1",
"@manypkg/get-packages": "^1.1.3",
"@preconstruct/cli": "^2.1.0",
"@preconstruct/cli": "^2.1.5",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/vue": "^6.4.0",
"@types/jest": "^24.0.23",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/StateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class StateMachine<
/**
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
*/
public getInitialState(): StateFrom<typeof this> {
public getInitialState(): State<TContext, TEvent, TResolvedTypesMeta> {
const { preInitialState } = this;
const nextState = resolveMicroTransition(
this,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export function fromMachine<TMachine extends AnyStateMachine>(
if (initialState) {
return initialState;
}
initialState = castedMachine.getInitialState();
initialState = castedMachine.getInitialState() as StateFrom<TMachine>;
return initialState;
}
};
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2039,10 +2039,10 @@
"@nodelib/fs.scandir" "2.1.4"
fastq "^1.6.0"

"@preconstruct/cli@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.1.0.tgz#76b30a8952f534f9f4a99862d7267815b6e3b57d"
integrity sha512-FfyWlZbinuv3be7yss8p9Yq87V88XKa6XUskeRSFDKgcgH1FwtTg9xYrEJm7j5QV4KThiQfPqoUN4m7hLxWlHg==
"@preconstruct/cli@^2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.1.5.tgz#f7f6d06809f382521589af15f67b87009b240c58"
integrity sha512-bMnGTkaotxq+xoOkXoUOfTFvxBX/ZUxukcacf3mx3G7Iz5m/T4ZGzSOU12pxl64e+rVWGTKlUsgaDSgyFkup0A==
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/core" "^7.7.7"
Expand Down

0 comments on commit 1dcf74b

Please sign in to comment.