microsoft / microsoft/TypeScript

In JS, JS containers can't be augmented inside an IIFE

Open
#26,278 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: JavaScript
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

var Ns = {};
(function () {
  Ns.x = 1
})()
Ns.x

Expected behavior:
No errors. Ns.x should be visible inside and outside the IIFE.

Actual behavior:
No errors, but completion dooesn't suggest 'x' as a property of Ns and Ns.x ends up with type any.

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 running the minimal JavaScript reproduction from the issue and compare the inferred type of Ns.x inside and outside the IIFE. Trace how the type checker handles property augmentation across the function boundary, including completion results. Done means Ns.x is inferred consistently and completion suggests x after the IIFE without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.