-
Notifications
You must be signed in to change notification settings - Fork 45
Why do I get "Avoid referencing unbound methods which may cause unintentional scoping of this
. eslint@typescript-eslint/unbound-method" in this case?
#102
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
There is nothing related to this plugin... And it's expected AFAIK. For the first one, For the other warnings, can just add OnInit(this: typeof methods) |
Do you mean we should change Svelte 3 types? |
It doesn't fix the warning. Can you please elaborate on this? |
Sorry about that, actually I don't have the problem. |
Yes. |
What's code do you want, the playground is simplified to show what the root cause. And which version of |
I changed the PLAYGROUND, as you can see here |
I'm using: "@typescript-eslint/eslint-plugin": "4.17.0",
"@typescript-eslint/parser": "4.17.0",
"typescript": "4.2.3", With this {
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",
"types": ["svelte", "node"]
},
"include": ["src/**/*", "types"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
} And module.exports = {
root: true,
overrides: [
{
files: ['./*.js', './.*.js'],
env: { node: true },
parserOptions: { sourceType: 'module', ecmaVersion: 2020 },
extends: ['eslint:recommended']
},
{
files: ['*.svelte'],
processor: 'svelte3/svelte3',
env: { es6: true, browser: true },
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
extraFileExtensions: ['.svelte']
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
plugins: ['svelte3', '@typescript-eslint'],
settings: { 'svelte3/typescript': require('typescript') },
rules: {
'@typescript-eslint/no-unsafe-member-access': 0
}
},
{
files: ['*.ts', '*.tsx'],
env: { es6: true, browser: true },
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
extraFileExtensions: ['.svelte']
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
plugins: ['svelte3', '@typescript-eslint'],
settings: { 'svelte3/typescript': require('typescript') }
}
]
} |
It works now on my Playground. But I still have that problem locally. What's the typescript version of the playground? |
Ok. I have the reproducible repo: https://github.com/frederikhors/issueWithThisAny |
If you enabled Anyway, it's a ts usage problem, not related to raised typescript-eslint/typescript-eslint#3197 for better message. |
Should we add |
No, that's up to the user to decide how strict he wants his type checking. |
I can close this. You people are wonderful people! |
This is necessary so ESLint does not complain about possibly unbound method access fixes sveltejs/eslint-plugin-svelte3#102
I'm using Svelte 3, Typescript and this code:
But
@typescript-eslint
is giving me these errors:Avoid referencing unbound methods which may cause unintentional scoping of this
2 times on line:Unsafe member access .Login on an any value
on line:Unsafe call of an any typed value
on line:How can I fix these warnings?
The text was updated successfully, but these errors were encountered: