Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: any string can be passed toinitial ortarget fields #5332

Open
Labels
@tomdohnal

Description

@tomdohnal

XState version

XState version 5

Description

I'd expect to get TS errors for this code:

constfeedbackMachine=setup({types:{context:{}as{feedback:string},events:{}as{type:"feedback.good"}|{type:"feedback.bad"},},}).createMachine({context:{feedback:"",},initial:"NON_EXISTING_STATE",// <---- i'd expect a TS error herestates:{idle:{on:{"feedback.good":{target:"NON_EXISTING_STATE",// <---- i'd expect a TS error here},},},},});

Expected result

I should only be allowed to pass valid state values (in my example onlyidle) to theinitial andtarget fields

Actual result

I'm allowed to pass a non existing state value to theinitial andtarget fields, which then yields runtime errors

Reproduction

https://codesandbox.io/p/devbox/great-leavitt-fw32ld?file=%2Fsrc%2FfeedbackMachine.ts%3A10%2C69

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp