diff --git a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts index 30ade9142..464471454 100644 --- a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts +++ b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts @@ -132,8 +132,12 @@ export function processInstanceScriptContent( // handle $store++, $store--, ++$store, --$store if ( (ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) && - parent.operator !== - ts.SyntaxKind.ExclamationToken /* `!$store` does not need processing */ + ![ + ts.SyntaxKind.ExclamationToken, // !$store + ts.SyntaxKind.PlusToken, // +$store + ts.SyntaxKind.MinusToken, // -$store + ts.SyntaxKind.TildeToken // ~$store + ].includes(parent.operator) /* `!$store` etc does not need processing */ ) { let simpleOperator: string; if (parent.operator === ts.SyntaxKind.PlusPlusToken) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/input.svelte deleted file mode 100644 index 713bbd294..000000000 --- a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/input.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/expected.tsx b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/expected.tsx similarity index 57% rename from packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/expected.tsx rename to packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/expected.tsx index 342e83562..5227e6003 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-exclamation-mark/expected.tsx +++ b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/expected.tsx @@ -6,10 +6,16 @@ function render() { const count = writable(0)/*Ωignore_startΩ*/;let $count = __sveltets_1_store_get(count);/*Ωignore_endΩ*/; const handler1 = () => !(__sveltets_1_store_get(count), $count) + const handler2 = () => +(__sveltets_1_store_get(count), $count) + const handler3 = () => -(__sveltets_1_store_get(count), $count) + const handler4 = () => ~(__sveltets_1_store_get(count), $count) ; () => (<> -); + + + +); return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/input.svelte new file mode 100644 index 000000000..d55482018 --- /dev/null +++ b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-with-unary-operators/input.svelte @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file