Skip to content

re-implement typescript-eslint's "no any" rules #390

Closed
@DetachHead

Description

@DetachHead

many of the typescript eslint rules don't seem to recognize svelte-specific things.

examples

events

<input
    type="checkbox"
    on:change={(event) => {
        // error: Unsafe assignment of an `any` value. (@typescript-eslint/no-unsafe-assignment)
        const foo = event.currentTarget.checked
    }}
/>

here, event is typed as Event & { currentTarget: EventTarget & HTMLInputElement } but the typescript-eslint plugin thinks it's any

$$Generics

<script lang="ts">
    type T = $$Generic<number>

    export let foo: T

    // Unsafe member access .toString on an `any` value. (@typescript-eslint/no-unsafe-member-access)
    // Unsafe call of an `any` typed value. (@typescript-eslint/no-unsafe-call)
    foo.toString()
</script>

here, the typescript-eslint plugin does not seem to understand $$Generic, so it treats them as any. (originally raised sveltejs/language-tools#1780)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions