Skip to content
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

TS18030: An optional chain cannot contain private identifiers #42734

Open
LongTengDao opened this issue Feb 10, 2021 · 2 comments · May be fixed by #60263
Open

TS18030: An optional chain cannot contain private identifiers #42734

LongTengDao opened this issue Feb 10, 2021 · 2 comments · May be fixed by #60263
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@LongTengDao
Copy link
Contributor

LongTengDao commented Feb 10, 2021

Bug Report

🔎 Search Terms

TS18030

🕗 Version & Regression Information

v4.1.3

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

class A {
	#p = 1;
	m (a? :A) {
		return a?.#p;
	}
}

🙁 Actual behavior

TS18030

🙂 Expected behavior

no error

@ajafff
Copy link
Contributor

ajafff commented Feb 10, 2021

When this was implemented, it was the behavior described by the spec. That's because optional chaining and private named instance fields were spec'ed in parallel and therefore couldn't reference each other's syntax.

The whole thing is discussed in tc39/proposal-optional-chaining#28
The stage 3 proposal for class fields added this syntax in tc39/proposal-class-fields#301

@RyanCavanaugh RyanCavanaugh added Working as Intended The behavior described is the intended behavior; this is not a bug Bug A bug in TypeScript and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Feb 10, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.3.0 milestone Feb 10, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Feb 10, 2021
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Jun 18, 2021
@Psychpsyo Psychpsyo linked a pull request Oct 17, 2024 that will close this issue
3 tasks
@Psychpsyo
Copy link

I have opened a PR to fix this, it is #60263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
7 participants