microsoft / microsoft/TypeScript

Emitter helper function could be override by user code

Open
#43,296 18 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Bug Report

🔎 Search Terms

emit, helper

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
⏯ Playground Link

https://www.typescriptlang.org/play?target=1#code/MYewdgzgLgBA+nApgDyosATCMC8MAUAlLgHwwDeMUAFgE4gDuMYiTAorfbUTAL4CwAKCHAANgEMI2AEIUY43DACMfERKkwAIjBRpMMigOGCAbuNowMilk01ER4CCFGIAdKJABzfBlfjCQA

💻 Code
const __extends = () => { throw new Error() }

class B { a = 1 }
class D extends B {}

var d = new D()
console.log(d.a)
🙁 Actual behavior

Exception

🙂 Expected behavior

console.log(1)

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 with the linked TypeScript Playground example and inspect how the compiler emits the __extends helper for the class inheritance code. Reproduce the exception, then trace the emitter's helper handling to determine why the user-defined helper overrides the generated one. Done means the example runs and logs 1 without the user code interfering with the emitted helper.

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.