GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — regression with private class members and loosing visibility · Issue #21516 · microsoft/TypeScript Closed Labels Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing code DescriptionUpgrading from TypeScript 2.6.2 to 2.7.1 and got a private variable scoping problem. TypeScript Version: 2.7.1 Search Terms: private property does not exist Code class Parent { pubValue: number; private priValue: number; private priXXX: number; constructor(value: number) { this.priValue = value; this.pubValue = 7; } cloneImpl(kind: boolean): Child | OtherChild { const copy = kind ? new Child(this.priValue) : new OtherChild(this.priValue); copy.pubValue = this.pubValue + 1; copy.priXXX = this.priXXX; return copy; } } class Child extends Parent { myData: number; clone() { return this.cloneImpl(true) as Child; } } class OtherChild extends Parent { clone() { return this.cloneImpl(false) as OtherChild; } } const child = new Child(6); child.clone(); Expected behavior: In typescript 2.6.2 the code was working and not generating an error. Since cloneImpl() is in the parent class it should have access to it's own private (tried with protected as well) variables. Actual behavior:
Playground Link: Related Issues: None found Activity
MetadataMetadataAssigneesLabelsBreaking ChangeWould introduce errors in existing codeWould introduce errors in existing code TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |