microsoft / microsoft/TypeScript

Wrong import suggestion in subpath pattern

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

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

Needs Investigation
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.75.1
  • OS Version: Darwin x64 22.1.0 (MacOS)

Steps to Reproduce:

  1. Install @neo4j-ndl/react@1.0.0-alpha-fafbc08
  2. Try to import an icon like <AdjustmentsHorizontalIconSolid /> in a JSX file.

The recommended import path is @neo4j-ndl/react/lib/types/icons while the correct based on the exports field would be @neo4j-ndl/react/icons

The modified package.json is looking like this:

{
  "name": "@neo4j-ndl/react",
  "version": "0.17.7",
  "sideEffects": false,
  "description": "React implementation of Neo4j Design System",
  "keywords": [
    "neo4j",
    "react",
    "design system",
    "needle",
    "ndl"
  ],
  "author": "Neo4j Inc.",
  "homepage": "",
  "license": "GPL-3.0",
  "main": "./lib/cjs/index.js",
  "module": "./lib/esm/index.js",
  "types": "./lib/types/index.d.ts",
  "exports": {
    "./icons": {
      "import": "./lib/esm/icons/index.js",
      "require": "./lib/cjs/icons/index.js",
      "types": "./lib/types/icons/index.d.ts"
    },
    ".": {
      "import": "./lib/esm/index.js",
      "require": "./lib/cjs/index.js",
      "types": "./lib/types/index.d.ts"
    }
  },
 ...
}

As a library publishers tried it also with WebStorm to see how it behaves and I can see that there it is imported as expected (video):

https://user-images.githubusercontent.com/12672541/219434237-a77ee748-c7b3-4995-a083-0690af3d9657.mp4

Also noticed, that if there is one module imported from @neo4j-ndl/react/icons then the suggestion works as expected (image):
CleanShot 2023-02-16 at 18 00 20@2x

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

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

はじめの一歩

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

調査の方向性

変更した package.json とその exports フィールドを使用して JSX ファイルで問題を再現し、@neo4j-ndl/react/icons パッケージの例から始めます。パッケージのサブパスパターンに対する import 提案の動作を追跡し、@neo4j-ndl/react/icons から import した後の動作するケースと比較します。提案されるパスが @neo4j-ndl/react/lib/types/icons ではなく @neo4j-ndl/react/icons になれば完了です。

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

評価

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

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

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