Skip to content

false positive @typescript-eslint/no-unsafe-assignment when using function bindings #741

@Theo-Steiner

Description

@Theo-Steiner

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

  • I'm using eslint-plugin-svelte. (*.svelte file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.
  • 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?

9.33.0

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

  • eslint-plugin-svelte@3.11.0
  • svelte-eslint-parser@1.3.1

What did you do?

configuration import js from "@eslint/js"; import sveltePlugin from "eslint-plugin-svelte"; import tseslint from "typescript-eslint"; export default tseslint.config( js.configs.recommended, ...tseslint.configs.recommended, ...sveltePlugin.configs["flat/recommended"], { files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], languageOptions: { parserOptions: { parser: tseslint.parser, extraFileExtensions: [".svelte"], projectService: true }, } }, { rules: { '@typescript-eslint/no-unsafe-assignment': 'error', } } );
<script lang="ts">
    let a = 'hello';
</script>

<input bind:value={
    () => a,
    (v) => a = v
}>

What did you expect to happen?

when using function bindings, typescript v seems to be inferred correctly as a string by typescript, so I assumed a = v would not be a safe assignment. (string to string)

What actually happened?

for some reason, v is parsed as any however, triggering the rule @typescript-eslint/no-unsafe-assignment

Link to GitHub Repo with Minimal Reproducible Example

playground

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions