Before You File a Bug Report Please Confirm You Have Done The Following...
What version of ESLint are you using?
10.4.1
What version of eslint-plugin-svelte and svelte-eslint-parser are you using?
- svelte-eslint-parser@1.8.0
- eslint-plugin-svelte@3.19.0
What did you do?
Configuration
// eslint.config.js
import prettier from 'eslint-config-prettier';
import path from 'node:path';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import { defineConfig, includeIgnoreFile } from 'eslint/config';
import globals from 'globals';
import ts from 'typescript-eslint';
const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
export default defineConfig(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
ts.configs.strictTypeChecked,
ts.configs.stylisticTypeChecked,
svelte.configs.recommended,
prettier,
svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
parserOptions: {
projectService: true
}
},
rules: {
'no-undef': 'off'
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte', '.svelte.ts', '.svelte.ts'],
parser: ts.parser
}
}
},
{
rules: {}
}
);
<!-- GenericSource.svelte -->
<script module lang="ts">
export type myType = string;
</script>
<!-- GenericConsumer.svelte -->
<script lang="ts">
import type { myType } from './GenericSource.svelte';
// 'myType' is an 'error' type that acts as 'any' and overrides all other types in this union type @typescript-eslint/no-redundant-type-constituents
type myOtherType = myType | string;
</script>
What did you expect to happen?
myType to resolve as string
What actually happened?
'myType' is an 'error' type that acts as 'any' and overrides all other types in this union type @typescript-eslint/no-redundant-type-constituents
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/glypse/svelteEslintTsScriptModuleBugRepro
Additional comments
- A
.svelte file that export types something from its <script module> works fine when the consumer uses it directly (type X = ImportedType).
- If the consumer uses that same imported type in a union (
type X = ImportedType | string) or intersection (type X = ImportedType & { ... }), the imported type resolves as an "error" type (collapsed to any), triggering @typescript-eslint/no-redundant-type-constituents.
Before You File a Bug Report Please Confirm You Have Done The Following...
*.sveltefile linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)What version of ESLint are you using?
10.4.1
What version of
eslint-plugin-svelteandsvelte-eslint-parserare you using?What did you do?
Configuration
What did you expect to happen?
myTypeto resolve asstringWhat actually happened?
'myType' is an 'error' type that acts as 'any' and overrides all other types in this union type @typescript-eslint/no-redundant-type-constituents
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/glypse/svelteEslintTsScriptModuleBugRepro
Additional comments
.sveltefile thatexport types something from its<script module>works fine when the consumer uses it directly (type X = ImportedType).type X = ImportedType | string) or intersection (type X = ImportedType & { ... }), the imported type resolves as an "error" type (collapsed toany), triggering@typescript-eslint/no-redundant-type-constituents.