microsoft / microsoft/TypeScript

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

オープン
#61,469 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
Domain: ES Modules Help Wanted Possible Improvement
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 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_

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

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

調査の方向性

ソースファイル、テスト、playground のいずれも指定されていません。import attribute を使用して TypeScript 5.8.2 で動作を再現し、属性値に対するコンパイラーの型付け経路を調査してください。値が any ではなく string として推論され、報告されたケースのリグレッションカバレッジが追加されていれば完了です。

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

評価

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

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

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