Open ota-meshi opened 7 months ago
And we need to hundle .svelte.js
file.
@ota-meshi
Apply correct type information to $derived.
Does this issue still exist?
The issue still exists.
In the following source code, it is reported by @typescript-eslint/no-unsafe-argument
.
export type Info = { n: number };
export function foo() {
let a: Info | null = $state(null);
a = null; // *
const d = $derived(a?.n ? fn(a.n) : null);
^^^
return {
get d() {
return d;
},
set(b: Info | null) {
a = b;
},
};
function fn(n: number) {
return n * 2;
}
}
(I don't often do a = null;
, but I think you can see that the type information is incorrect.)
DEMO:
Ah got it!
Having a rough time figuring out how to set this up with the new flat config.
Having a rough time figuring out how to set this up with the new flat config.
I got it working using the following (I do not know your issue, but maybe it helps):
...eslintPluginSvelte.configs['flat/recommended'].map(({ rules, ...rest }) => ({
// Workaround since svelte-eslint's typings are mismatched with ts-eslint's
rules: {
...rules
},
...rest
})),
@mikededo were you able to get it to parse .svelte files with typescript? That is specifically what I have not been able to get working.
@pboling Yes. As a heads up, make sure that you update your dependencies as @typescrip-eslint/eslint-plugin
and @typescript-eslint/parser
have been updated into typescript-eslint
. See the following https://github.com/typescript-eslint/typescript-eslint/pull/7935 PR, in which support for flat configs was introduced.
Let me share the full configuration. You'll probably have to adapt things to your liking:
eslint.config.mjs
Again, this is my config "as is", so not everything here is what you need in order to make the parser work.
Thanks! I was able to get mine working, and I did not need to use FlatCompat
! I posted it here:
https://github.com/sveltejs/eslint-plugin-svelte/issues/732
421
425
$derived
.430
*.svelte.js
and*.svelte.ts
files parsable.426
$effect.root
(added in 5.0.0-next.14) #446$inspect
(added in 5.0.0-next.16) #446$inspect
API (changed in 5.0.0-next.21) (#467)(Finally, it changed to$state.raw
$state.frozen
. https://github.com/sveltejs/svelte/pull/9851)$state.frozen
#466$bindable
scope analysis. https://github.com/sveltejs/svelte-eslint-parser/pull/527 See https://github.com/sveltejs/eslint-plugin-svelte/issues/768$effect.active()
renamed to$effect.tracking()
{#snippet}
and{@render}
https://svelte-5-preview.vercel.app/docs/snippets431
Support for new event-handlers https://svelte-5-preview.vercel.app/docs/event-handlersonxxx
seems to be the same as the attribute (prop). So no work is required with this parser. However, I think some work is needed with the eslint-plugin.[ ] Waiting for Svelte v5 GA.
Related to https://github.com/sveltejs/eslint-plugin-svelte/issues/587