Description
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.43.0
What version of eslint-plugin-svelte
are you using?
2.10.1
What did you do?
Configuration
module.exports = {
root: true,
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
sourceType: "module",
ecmaVersion: 2020,
extraFileExtensions: [".svelte"]
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser"
}
}
]
};
<script lang="ts" generics="T">
import { createEventDispatcher } from "svelte";
// Or type T = $$Generic; (same result)
/** */
const dispatch = createEventDispatcher<{ change: Promise<T> }>();
export let value: T;
/** */
function test(): void {
const promise = new Promise<T>((resolve) => resolve(value));
dispatch("change", promise);
}
</script>
What did you expect to happen?
That ESLint would be able to interpret the symbol T
What actually happened?
ESLint is not able to interpret the symbol T
:
6:59 error 'T' is not defined no-undef
8:20 error 'T' is not defined no-undef
Link to GitHub Repo with Minimal Reproducible Example
Additional comments
Note that this is not an issue in eslint-plugin-svelte3.
Also don't know if generic="T"
attribute or type T = $$Generic
declaration is the preferred way of dealing with generics in components, but both seem to not work.
Metadata
Metadata
Assignees
Labels
No labels