Open
Description
#87 uncovered some limitations when using type-aware rules. Some of these are fixed by #88 , but not all of them. Reactive assignments and store subscriptions will fail:
<script lang="ts">
import { writable } from 'svelte/store';
const store = writable([]);
$store.length; // wrong no-unsafe-member-access error
$: assignment = [];
assignment.length; // wrong no-unsafe-member-access error
// You can work around this by doing
let another_assignment: string[];
$: another_assignment = [];
another_assignment.length; // OK
</script>
This is because the transformation just prepends generated let X
statements above the code, with no specific type set to it. For it to work correctly, we would need to do transformations inline:
$: assignment = ..
-->let assignment = ..
(but only if user did not declare thelet
himself)const store = writable(...)
-->const store = writable(..);let $store = get_store_value(store)
(whereget_store_value
is a fake function returning theValue
inStore<Value>
)
This would be similar to how we transform code in svelte2tsx
for the intellisense features. The hard part is getting the line mappings correctly afterwards.