Description
I noticed a problem with syntax highlighting, auto-import, svelte-check and Quick Fix options for importing Typescript types.
E.g. for this code
<script lang="ts">
import { Link } from 'svelte-navigator'
export let navigate: NavigateFn
</script>
-
auto-import
During typing the word "NavigateFn" intellisense displays a tooltip to auto-import this type from svelte-navigator. The auto-import adds the type to existing import, resulting in:
import { Link, NavigateFn } from 'svelte-navigator'
-
Quick Fix
The same happens when choosing a Quick Fix option to add NavigateFn to existing import (this is the only option to choose). -
syntax highlighting
All is looking ok inside VSCode, despite adding a compiler option in tsconfig.json:
"importsNotUsedAsValues": "error"
Setting this option to "remove" or "preserve" seems to have no impact on VSCode behavior, either. -
svelte-check
No error
During runtime there is an error:
SyntaxError: The requested module '/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte-navigator/src/index.js' does not provide an export named 'NavigateFn'
The expected behavior is to:
-
either display an error inside VSCode and in svelte-check, according to the
"importsNotUsedAsValues": "error"
typescript setting -
or make auto-import and Quick Fix use type-only import for types, resulting in code:
import { Link } from 'svelte-navigator'
import type { NavigateFn } from 'svelte-navigator'