diff --git a/.changeset/flat-socks-tie.md b/.changeset/flat-socks-tie.md new file mode 100644 index 00000000..d03a47e7 --- /dev/null +++ b/.changeset/flat-socks-tie.md @@ -0,0 +1,5 @@ +--- +"stately-vscode": patch +--- + +Updated `xsm` snippet for TypeScript machines to make it easier to type context and events. diff --git a/apps/extension/client/snippets/xstate.code-snippets b/apps/extension/client/snippets/xstate.code-snippets index 1f424421..3d7eb306 100644 --- a/apps/extension/client/snippets/xstate.code-snippets +++ b/apps/extension/client/snippets/xstate.code-snippets @@ -13,7 +13,7 @@ "prefix": "xsm", "body": [ "import { createMachine } from 'xstate';", - "const ${1:nameOf}Machine = createMachine({\n\tid: '${1:nameOf}',\n\ttsTypes: {},\n\tschema: {\n\t\tcontext: {} as { value: string },\n\t\tevents: {} as { type: 'FOO' },\n\t},\n\tcontext: {\n\t\tvalue: '',\n\t},\n\tinitial: '${2:initialState}',\n\tstates: {\n\t\t${2:initialState}: {$0},\n\t},\n});" + "const ${1:nameOf}Machine = createMachine({\n\tid: '${1:nameOf}',\n\ttsTypes: {},\n\tschema: {\n\t\tcontext: {} as { ${2:contextType} },\n\t\tevents: {} as { type: '${3:eventType}' },\n\t},\n\tcontext: {\n\t\t${4:initialContextValue},\n\t},\n\tinitial: '${5:initialState}',\n\tstates: {\n\t\t${5:initialState}: {},\n\t},\n});$0" ], "description": "Outline for XState Typegen Machine" }