-
-
Notifications
You must be signed in to change notification settings - Fork 48
False positive when accessing custom component props #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for posting the issue. I already know the problem. https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files At least I have it working in my project. If you are interested in it, please try it and give us feedback. |
Oh yes, that seems to do it. Thanks a bunch! Any chance you also have an idea why |
I think it's because all default imported classes from https://github.com/sveltejs/svelte/blob/master/src/runtime/ambient.ts |
Ok, thanks. I know, this is not in the scope of this issue, but I am really lost on this. Do you know/could point me to something on how to properly type the component to make TS raise an error when I try to access an undefined member? |
You can try the typescript-eslint-parser-for-extra-files. This is a project for passing proper types to |
Let's use typescript-eslint-parser-for-extra-files |
Before You File a Bug Report Please Confirm You Have Done The Following...
What version of ESLint are you using?
8.26.0
What version of
eslint-plugin-svelte
are you using?2.12.0
What did you do?
Configuration
Consider this component:
I am importing it here:
When I run
pnpm lint
, I get an error like this:However the
api
property is actually typed correctly and is not of typeany
. This is also correctly detected by Typescript, yet ESLint seems to not like it:(Please also note that
.doesNotExist
does not cause any trouble. No idea why that would be ...)What did you expect to happen?
I expected ESLint to not throw the error since
.api
is correctly typed.What actually happened?
ESLint "thinks"
.api
is of typeany
and thus raises an error.Link to GitHub Repo with Minimal Reproducible Example
https://github.com/ptrxyz/eslint-unsafe-member-example/tree/svelte-eslint-parser
Additional comments
.api
does also no solve this issue.The text was updated successfully, but these errors were encountered: