sveltejs/language-tools

Wrong path is resolved when the imports differ in case only

开放

#1,882 创建于 2023年2月20日

 (5 条评论) (0 个反应) (0 位负责人)TypeScript (247 个派生)auto 404
bughelp wanted

仓库指标

星标
 (1,437 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南