microsoft / microsoft/TypeScript

Image element src property does not allow URL assignment

Open
#43,066 6 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.