Skip to content

Incorrect ES5 transpilation for 'this' usage in lambda as a constructor default parameter #55637

Description

🔎 Search Terms

ES5, this alias

🕗 Version & Regression Information

  • This changed between versions 5.1.6 and 5.2.2

⏯ Playground Link

https://www.typescriptlang.org/play?target=1&ts=5.2.2#code/MYGwhgzhAEDqBOYAOSCm9oG8BQ1rAHsA7CAF3gFdhSD4AKXPaANzBAEsATMU1aAXmh0KJMADNUALiwBfAJQCAfNFIALdhAB0rDt17DREuQpxMWbLj1R1M8gNyMZ2RknjtWvc7qt1SATzQAVUMpaDAiPzlpACMCAhBUcKxGPHhUUgp4IhVKVAc8JydsIlQAdzhEFHQ6OQcgA

💻 Code

// @target: es5// @showEmit: trueclassWrapper{constructor(validate=(unsafe: {})=>this.validate(unsafe)){validate({});}privatevalidate(typeUnsafe: any): boolean{returntrue;}}newWrapper();

Target: ES5

🙁 Actual behavior

Cannot read properties of undefined (reading 'validate') 

🙂 Expected behavior

No error (as with untranspiled version or with TS5.1.6)

Additional information about the issue

No response

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptFix AvailableA PR has been opened for this issueHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-repros

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions