You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The type of private fields in a class cannot be used in generic #30882
classFoo<T>{privatea!: T;// when it is public, no error occurs below}typeBar<TextendsRecord<string,Foo<any>>>=T[keyofT]["a"];// ts(2536) occurs, while autocomplete works well.typeA=Foo<number>["a"];// it works always!
Expected behavior:
Not treating it as an error. If it is inteneded, at least the error message should be more helpful. Actual behavior:
ts(2536) occurs. Playground Link Related Issues:
Activity
RyanCavanaugh commentedon Apr 12, 2019
Nathan Shively-Sanders (@sandersn) not 100% convinced it's a bug per se, but it well might be. The error is indeed weird
andrewbranch commentedon Jun 24, 2019
This isn’t a bug, but I improved the error message to make it clear that it’s on purpose: