microsoft / microsoft/TypeScript
Image element src property does not allow URL assignment
Open
Nobody has claimed this yet.
Experience Enhancement
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Bug Report
🔎 Search Terms
image src dom
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 4.3.0
⏯ Playground Link
Playground link with relevant code
💻 Code
let image = document.createElement('img');
image.src = new URL("http://google.com");
console.log(image.src)
🙁 Actual behavior
Type 'URL' is not assignable to type 'string'.(2322)
🙂 Expected behavior
Compiles cleanly (confirmed supported per https://github.com/whatwg/html/issues/6440)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the assignment in the linked TypeScript Playground with document.createElement('img') and new URL. Trace the DOM type definition used for image.src and verify that URL assignment compiles cleanly without weakening existing string assignment behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100