Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the declared signature of one of the StateMachine's methods to avoid using a private name this #3389

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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