sveltejs/language-tools

Wrong path is resolved when the imports differ in case only

Open

#1,882 opened on Feb 20, 2023

 (5 comments) (0 reactions) (0 assignees)TypeScript (247 forks)auto 404
bughelp wanted

Repository metrics

Stars
 (1,437 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the bug

When there are 2 imports which differ in case only, svelte-check resolves the path wrongly. Eg:

index.ts

import { Favs } from '@core/Favs'; // import 1
import favs from '@core/favs'; // import 2

It fails with an error

Module '"path/to/named/folder/core/Favs"' has no default export.

But it has default export for sure, TS type check works like a charm.

core/Favs.ts

export const Favs = 'I am Favs class';

core/favs.ts

export default 'I am favs utils';

The order counts, when you change index.ts file as following:

import favs from '@core/favs'; // import 2
import { Favs } from '@core/Favs'; // import 1

The error changed to:

Module '"@core/favs"' has no exported member 'Favs'. Did you mean to use 'import Favs from "@core/favs"' instead?

Reproduction

See "Describe the bug" section

Expected behaviour

It should resolve both paths correctly, as tsc does.

System Info

  • OS: MacOS (local) & Debian (CICD)
  • IDE: VSCode & CICD terminal

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

Contributor guide