Open DetachHead opened 1 year ago
Where are the types for GET
sourced from? I don't understand the code you provided because there are no type declarations. Could you please share a repository to reproduce the issue?
I've only made static sites using svelte kit, so I'm not sure :sweat:
sveltekit infers the types so you don't have to annotate them explicitly. i've updated the issue with a github repo. to reproduce the error, checkout that branch then run the following commands
npm install
npm run check
npx eslint .
Think you mean npx eslint .
true. i added ./node_modules/.bin
to my path so i forgot about npx
. updated my comment
Inferring types is a new feature: https://svelte.dev/blog/zero-config-type-safety
Thank you for the repo to reproduce.
It seems that the svelte language server and svelte-check assign their own types. (Because raw tsc
command fails.)
I think we should check how it is implemented 👀.
memo: Perhaps the following source code is injecting the type.
Hmm.. We may need new typescript parser for the eslint (not svelte parser). We should check if it integrates well with svelte2tsx
.
I still have this issue, is there any progress on this, or any known workaround/solution?
Another minimal repro here: https://github.com/thenbe/repro-eslint-svelte-typecheck
pnpm install
pnpm eslint src/routes/+page.svelte
Expected: We should get no eslint errors. Actual: We get two eslint errors. Error message:
src/routes/+page.svelte
7:20 error Unsafe member access .url on an `any` value @typescript-eslint/no-unsafe-member-access
11:8 error Unsafe member access .greeting on an `any` value @typescript-eslint/no-unsafe-member-access
svelte-check
(i.e. pnpm run check
) passes without errors. Only eslint shows error.
Got the same issue....
So,
export async function load({ fetch }) {
return await fetch('/foo');
}
this causes an error because fetch
is inferred as any
in eslint.
However, this works fine for svelte-check and svelte lsp
Before You File a Bug Report Please Confirm You Have Done The Following...
What version of ESLint are you using?
8.33.0
What version of
eslint-plugin-svelte
are you using?2.22.0
What did you do?
Configuration
```json { "rules": { "@typescript-eslint/no-unsafe-member-access": "error" } } ```What did you expect to happen?
no error
What actually happened?
@typescript-eslint/no-unsafe-member-access
errorLink to GitHub Repo with Minimal Reproducible Example
https://github.com/DetachHead/eslint-plugin-svelte-repros/commit/7bf800de39d834d70525c1e5cc08343ce5fdb98f
Additional comments
originally raised at https://github.com/ota-meshi/eslint-plugin-svelte/issues/390#issuecomment-1477369726