Skip to content
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

Error when @typescript-eslint/recommended-requiring-type-checking is used #442

Closed
2 tasks done
sidharthv96 opened this issue Apr 24, 2023 · 1 comment · Fixed by #447
Closed
2 tasks done

Error when @typescript-eslint/recommended-requiring-type-checking is used #442

sidharthv96 opened this issue Apr 24, 2023 · 1 comment · Fixed by #447
Labels
enhancement New feature or request feat: typescript

Comments

@sidharthv96
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.39.0

What version of eslint-plugin-svelte are you using?

2.26.0

What did you do?

This error only happens when enabling 'plugin:@typescript-eslint/recommended-requiring-type-checking'.

Configuration
module.exports = {
	root: true,
	parser: '@typescript-eslint/parser',
	extends: [
		'eslint:recommended',
		'plugin:@typescript-eslint/recommended',
		'plugin:@typescript-eslint/recommended-requiring-type-checking',
		'plugin:svelte/recommended',
		'plugin:svelte/prettier',
		'prettier'
	],
	plugins: ['@typescript-eslint'],
	ignorePatterns: ['*.cjs'],
	overrides: [
		{
			files: ['*.svelte'],
			parser: 'svelte-eslint-parser',
			parserOptions: {
				parser: '@typescript-eslint/parser'
			}
		}
	],
	parserOptions: {
		sourceType: 'module',
		ecmaVersion: 2020,
		project: './tsconfig.json',
		extraFileExtensions: ['.svelte']
	},
	env: {
		browser: true,
		es2017: true,
		node: true
	}
};
<form
  method="POST"
  action="?/test"
  use:enhance={() => {
	return ({ result, update }) => {
		if (result.type === 'success') {
			const x = result.data?.hello;
			console.log({ x });
		}
		update();
	};
}}
>

What did you expect to happen?

No errors as result.type and result.data are recognized by typescript.
image

What actually happened?

  16:9   error  Unsafe member access .type on an `any` value  @typescript-eslint/no-unsafe-member-access
  17:12  error  Unsafe assignment of an `any` value           @typescript-eslint/no-unsafe-assignment
  17:16  error  Unsafe member access .data on an `any` value  @typescript-eslint/no-unsafe-member-access
  18:20  error  Unsafe assignment of an `any` value           @typescript-eslint/no-unsafe-assignment
  20:5   error  Unsafe call of an `any` typed value           @typescript-eslint/no-unsafe-call

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/sidharthv96/sk-test

Additional comments

No response

@ota-meshi
Copy link
Member

Thank you for reporting the issue.
Currently those rules and the use: directive seem to be incompatible.
Please use settings.svelte.ignoreWarnings as a workaround until the issue is resolved.

https://sveltejs.github.io/eslint-plugin-svelte/user-guide/#settings-svelte-ignore-warnings

@ota-meshi ota-meshi added bug Something isn't working feat: typescript enhancement New feature or request and removed bug Something isn't working labels Apr 25, 2023
@ota-meshi ota-meshi linked a pull request Apr 26, 2023 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants