-
Notifications
You must be signed in to change notification settings - Fork 40
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
"Jump to definition" doesn't work with v5's setup(...)
API
#479
Comments
We are in the process of rewriting the extension to improve v5 compatibility. This feature isn't exactly on our MVP list but the rewrite will allow us to implement this soon after we manage to cut that first MVP release. |
That's great to hear! I think this specifically would make a big difference for adoption. My take as a developer FWIW is that XState's biggest DX challenge is the whole string-literals-that-refer-to-functions thing, and that's largely to do with the friction that comes from not having IDE support for going back and forth between the functions and their string references. |
I now really really wonder if we just couldn't improve this situation in TS itself. It doesn't sound unreasonable for this to work: declare function setup<TActions>(_: { actions: TActions }): {
createMachine: (config: { entry: keyof TActions }) => void;
};
setup({
actions: {
doStuff: () => {},
doMoreStuff: () => {},
},
}).createMachine({
// "go to definition" on the string here should bring us to the action's definition
entry: "doStuff",
}); Our situation is, of course, a little bit more complex and involves even more indirection... but making the above work could be the first step to improving our situation. All of this is highly related to this open ticket: microsoft/TypeScript#49033 note for myself: I think there is a good chance that this could be improved by creating the |
This feature advertised on the extension README doesn't seem to work with APIs recommended for setup in v5. My state machine is instantiated like this
As far as I can tell:
target
states and it'll jump to the correct state definition. It seems to work when the target states are at the root level, or when they're linked via id like#disconnected
.In this screen capture, everywhere I click is a command-click, so should jump to definition if one is available.
Screen.Recording.2024-03-05.at.7.33.55.PM.mov
The text was updated successfully, but these errors were encountered: