Skip to content

3.9 regression: reference error setting default values in nested parameter destructuring #38243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maxdavidson opened this issue Apr 29, 2020 · 0 comments · Fixed by #38351
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@maxdavidson
Copy link

TypeScript Version: 3.9.1-rc, 4.0.0-dev.20200428

Search Terms: cannot reference identifier

Code

function test0({ a = 0, b = a } = {}) {
	return { a, b };
}

function test1({ c: { a = 0, b = a } = {} } = {}) {
	return { a, b };
}

Expected behavior: Doesn't fail

Actual behavior: Fails with Parameter '{ a = 0, b = a }' cannot reference identifier 'a' declared after it.(2373)

Playground Link: https://www.typescriptlang.org/play/?noImplicitAny=false&ts=4.0.0-dev.20200428&ssl=8&ssc=1&pln=1&pc=1#code/GYVwdgxgLglg9mABFApgZygBgBQG9ECGiAvIpgDSIBGJhiAvrbvQJSK4BQi3iATilBC8k+ApRr0A3B3ocOoSLATJ0UAIx5EEAFzs6pCtVpFGpZgyat2XHv0HC9Yo1JkcgA

Related Issues: #38130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants