microsoft / microsoft/TypeScript

Wrong import suggestion in subpath pattern

Offen
#52,870 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs Investigation
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem in einer JSX-Datei mit dem modifizierten package.json und dessen exports-Feld, beginnend mit dem Beispiel für das Paket @neo4j-ndl/react/icons. Verfolge das Verhalten der Importvorschläge für ein Paket-Subpath-Muster und vergleiche es mit dem funktionierenden Fall nach einem Import aus @neo4j-ndl/react/icons. Die Aufgabe ist abgeschlossen, wenn der vorgeschlagene Pfad @neo4j-ndl/react/icons statt @neo4j-ndl/react/lib/types/icons lautet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.