microsoft / microsoft/TypeScript

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

Open
#61,469 5 comments 0 reactions 0 assignees View on GitHub
Domain: ES Modules Help Wanted Possible Improvement
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

Research direction

No source file, test, or playground is named. Reproduce the behavior with TypeScript 5.8.2 using an import attribute and inspect the compiler's typing path for the attribute value. Done means the value is inferred as string rather than any, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.