-
-
Notifications
You must be signed in to change notification settings - Fork 48
re-implement typescript-eslint's "no any" rules #390
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Thank you for posting the issue. About event types: About I don't want to fully support it yet to avoid a lot of breaking changes. |
would it be possible to use this is the output of /// <reference types="svelte" />
function render() {
;async () => {
{
svelteHTML.createElement('input', {
type: 'checkbox',
'on:change': (event) => {
const foo = event.currentTarget.checked
},
})
}
}
return { props: /** @type {Record<string, never>} */ {}, slots: {}, events: {} }
}
export default class extends __sveltets_2_createSvelte2TsxComponent(
__sveltets_2_partial(__sveltets_2_with_any_event(render())),
) {} here, the |
I think it is very difficult. |
i found another example where a type is incorrectly considered to be <!-- Foo.svelte -->
<script lang="ts" context="module">
export type Foo = number
</script> <!-- Bar.svelte -->
<script lang="ts">
import type { Foo } from './Foo.svelte'
const asdf: Foo = 1
// Unsafe member access .fdsa on an `any` value. (@typescript-eslint/no-unsafe-member-access)
// Unsafe call of an `any` typed value. (@typescript-eslint/no-unsafe-call)
asdf.toString()
</script> |
I know it. #298 |
another example is the sveltekit API route types that are automatically inferred, but not recognised by typescript-eslint: export const GET = async ({ request }) => {
// request is not any, since it's inferred as Request by sveltekit
request.headers // error: @typescript-eslint/no-unsafe-member-access
} |
Could you please open another issue to better manage those issues? |
done #413 |
As for |
many of the typescript eslint rules don't seem to recognize svelte-specific things.
examples
events
here,
event
is typed asEvent & { currentTarget: EventTarget & HTMLInputElement }
but the typescript-eslint plugin thinks it'sany
$$Generic
shere, the typescript-eslint plugin does not seem to understand
$$Generic
, so it treats them asany
. (originally raised sveltejs/language-tools#1780)The text was updated successfully, but these errors were encountered: