Skip to content

Optional chaining arg default with this #37852

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
samdenty opened this issue Apr 9, 2020 · 2 comments
Closed

Optional chaining arg default with this #37852

samdenty opened this issue Apr 9, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@samdenty
Copy link

samdenty commented Apr 9, 2020

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms: Optional chaining, argument default this

Code

class Test {
    public c(a = this.a?.b) {}
}

Expected behavior:

Shouldn't throw reference error

Actual behavior:

Throws reference error for _a

c(a = (_a = this.a) === null || _a === void 0 ? void 0 : _a.b) {
  var _a;
}

Playground Link: https://www.typescriptlang.org/play/index.html#code/FAYwNghgzlAEAqBTKAXWBvYtuwA4FcAjMASxFglgF4NZCAuWARlgF9gOc8jTyQAKSjRQALElAB0EAPwTCASgycc7dsAB2iAO4JkKfvIkD5QA

@samdenty samdenty changed the title Optional chaining arg default wit this Optional chaining arg default with this Apr 9, 2020
@DanielRosenwasser
Copy link
Member

Duplicate of #36295

@DanielRosenwasser DanielRosenwasser marked this as a duplicate of #36295 Apr 9, 2020
@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Apr 9, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants