microsoft / microsoft/TypeScript

"File name X differs from Y only in casing." problem when using webpack style path alias

オープン
#53,767 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: Module Resolution Help Wanted
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Type: Bug

I am using webpack-style path aliases for Javascript imports. For example:

import { Pricing } from 'SRC/pricing.mjs';

with a jsconfig.json that looks like this:

{
    "compilerOptions": {
      "module": "es6",
      "target": "es6",
    },
    "baseUrl": ".",
    "paths": {
      "SRC/*": ["./src/*"]
    }
}

With the result that SRC/pricing.mjs is replaced with {baseurl}/src/pricing.mjs no matter what directory the importing code lives in.

This works fine, however I get warnings like the following in the 'Problems' view:

File name '<path to project>/SRC/pricing.mjs' differs from already included file name '<path to project>/src/pricing.mjs' only in casing.
  The file is in the program because:
    Matched by default include pattern '**/*'
    Imported via 'SRC/pricing.mjs' from file '<path to project>/src/page/index-client.js'
    Imported via 'SRC/pricing.mjs' from file '<path to project>/src/page/index-html.js'
    Imported via 'SRC/pricing.mjs' from file '<path to project>/src/page/pricing-calculator-client.js'
    Imported via 'SRC/pricing.mjs' from file '<path to project>/src/page/pricing-calculator-html.js'

I think the code that checks for case insensitivity issues might not be fully / correctly aware of how jsconfig.son path aliases work.

I can workaround the issue by adding "forceConsistentCasingInFileNames": false to compilerOptions however then I don't get the general benefit of this problem detection.

If I use SRC2 or $SRC instead of SRC everything is fine.

VS Code version: Code 1.77.3 (Universal) (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:19:37.325Z)
OS version: Darwin arm64 22.4.0
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs Apple M1 Pro (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.23GB free)
Process Argv --disable-extensions . --crash-reporter-id eef3215b-4736-49de-82a2-9fef6d51c723
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vscaac:30438847
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyonecf:30548226
nodejswelcome1cf:30587006
2e4cg342:30602488
pyind779:30671433
89544117:30613380
vscrp:30673768
pythonsymbol12:30671437
2i9eh265:30646982
vsctsb:30705553
pythonb192:30669360
defaultazurewalk:30687958
pythonms35:30701012
pythonclientmv:30708685

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提示された jsconfig.json と SRC/pricing.mjs の import を使って診断を再現します。forceConsistentCasingInFileNames を有効にしたまま、エイリアス化されたパスと実際の src/pricing.mjs パスがどのように報告されるかを比較します。一般的な大文字と小文字のチェックを無効にせず、有効な webpack スタイルのエイリアスで大文字と小文字に関する警告が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。