microsoft / microsoft/TypeScript

Wrong import attribute typed as any, but should be typed as string

Offen
#61,469 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Domain: ES Modules Help Wanted Possible Improvement
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

### 🔎 Search Terms

According to the [documentation at MDN for Import attributes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with), the attribute value ie. [dataN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with#datan) is of type`string`.

In my VSCode setup using Typescript 5.8.2, this is typed as `any` in my .ts file:

Image

My tsconfig is as follows:

```
{
"exclude": ["dist"],
"compilerOptions": {
"jsx": "react",
"target": "ES2022",
"module": "esnext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"strict": true,
"skipLibCheck": true,
"noImplicitAny": true,
"isolatedModules": false
}
}
```

### 🕗 Version & Regression Information

- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______

### ⏯ Playground Link

_No response_

### 💻 Code

```ts
// Your code here
```

### 🙁 Actual behavior

Import attribute is typed as any instead of string.

### 🙂 Expected behavior

Import attribute should be typed as string.

### Additional information about the issue

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Es wird keine Quelldatei, kein Test und kein Playground genannt. Reproduziere das Verhalten mit TypeScript 5.8.2 unter Verwendung eines import attribute und untersuche den Typisierungspfad des Compilers für den Attributwert. Als erledigt gilt die Aufgabe, wenn der Wert als string statt als any inferiert wird und eine Regressionstestabdeckung für den gemeldeten Fall vorhanden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 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.