cannot redeclare block scoped variable postMessage()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- compilers
Research direction
Start with the SharedWorker example and the separate tsconfig.json files in the NPM-workspaces monorepo. Inspect the duplicate postMessage declarations in lib.dom.d.ts and determine why they enter the same TypeScript program; verify the fix by rebuilding the affected modules and confirming the diagnostic is gone.
Written by the indexing model from the issue text.
Description
🔎 Search Terms
"cannot redeclare block scope variable postMessage typescript"
🕗 Version & Regression Information
TS version: ^5.1.6
⏯ Playground Link
Can't use workers in Playground
💻 Code
const worker = new SharedWorker(new URL('./worker.js', import.meta.url))
/* ... */
worker.port.addEventListener('message', e => {
if (!e.data?.type) {
return
}
switch (e.data.type) {
case 'get_tabs': {
worker.port.postMessage({ //Error here
type: 'share_tab_id',
tab_id: tabId
})
}
/* ... */
🙁 Actual behavior
I'm getting a Cannot redeclare block-scoped variable 'postMessage' error coming from TypeScript itself. I checked the file (lib.dom.d.ts) and it looks like the postMessage variable is getting declared twice
🙂 Expected behavior
Expect to have single declaration of postMessage and no error.
Additional information about the issue
I'm using a monorepo with NPM workspaces. Each module has a separate tsconfig.json and are built separately
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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.
More from microsoft/TypeScript
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/TypeScript#64322 · 2 comments · 1 reaction · 2 assignees ·
-
Possible Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64278 · 1 comment · 1 reaction ·
-
Docs
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/TypeScript#64118 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
microsoft/TypeScript#64094 ·
-
Docs
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/TypeScript#63959 · 5 comments ·
All issues in microsoft/TypeScript
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100