Skip to content
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
15 changes: 10 additions & 5 deletions packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,17 @@ export function processInstanceScriptContent(
};

const handleStore = (ident: ts.Identifier, parent: ts.Node) => {
// ignore "typeof $store"
if (parent && parent.kind === ts.SyntaxKind.TypeQuery) {
return;
}
// ignore break
if (parent && parent.kind === ts.SyntaxKind.BreakStatement) {
return;
}

const storename = ident.getText().slice(1); // drop the $
// handle assign to
// eslint-disable-next-line max-len
if (
parent &&
ts.isBinaryExpression(parent) &&
Expand All @@ -160,10 +168,7 @@ export function processInstanceScriptContent(
str.appendLeft(parent.end + astOffset, ')');
return;
}
// ignore break
if (parent && parent.kind === ts.SyntaxKind.BreakStatement) {
return;
}

// handle Assignment operators ($store +=, -=, *=, /=, %=, **=, etc.)
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment
const operators = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
///<reference types="svelte" />
<></>;
import {writable} from "svelte/store";
function render() {


const foo = writable(1)/*Ωignore_startΩ*/;let $foo = __sveltets_store_get(foo);/*Ωignore_endΩ*/;
type Foo = typeof $foo;
;
() => (<></>);
return { props: {}, slots: {}, getters: {}, events: {} }}

export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
import {writable} from "svelte/store";
const foo = writable(1);
type Foo = typeof $foo;
</script>