-
Notifications
You must be signed in to change notification settings - Fork 568
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
Unify the way anonymous class symbols are printed in error messages #731
base: main
Are you sure you want to change the base?
Conversation
C.getInstance().#field; // Error | ||
~~~~~~ | ||
-!!! error TS18013: Property '#field' is not accessible outside class '(anonymous)' because it has a private identifier. | ||
+!!! error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. | ||
+!!! error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to add this to accepted baselines but I'm not sure how to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this line to submoduleAccepted.txt:
privateNameMethodClassExpression.errors.txt.diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
C.getInstance().#field; // Error | ||
~~~~~~ | ||
!!! error TS18013: Property '#field' is not accessible outside class '(Missing)' because it has a private identifier. | ||
!!! error TS18013: Property '#field' is not accessible outside class 'C' because it has a private identifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strada would print (anonymous)
here but this has an inferrable~ name from the declaration and I think it's better to use it. Using it is not a new thing to do.
!!! error TS2322: Type '(Anonymous class)' is not assignable to type 'A'. | ||
!!! error TS2322: Property '#foo' in type '(Anonymous class)' refers to a different member that cannot be accessed from within type 'A'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strada would print (Anonymous class)
in the first line here and then (anonymous)
in the second line. So I think this change unifying it is a good thing.
Note this is a new test case, not one from Strada.
@@ -4272,8 +4271,8 @@ func (r *Relater) reportUnmatchedProperty(source *Type, target *Type, unmatchedP | |||
privateIdentifierDescription := unmatchedProperty.ValueDeclaration.Name().Text() | |||
symbolTableKey := binder.GetSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription) | |||
if r.c.getPropertyOfType(source, symbolTableKey) != nil { | |||
sourceName := scanner.DeclarationNameToString(ast.GetNameOfDeclaration(source.symbol.ValueDeclaration)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous behavior here was already diverging slightly from Strada for those anonymous classes (IMHO, in a good way)
I'm not 100% clear why |
This isn't particularly consistent: TS playground. I am surprised now that the first error mentions
|
This is slightly different from Strada in two ways:
GetNameOfDeclaration
is preferred now(anonymous)
becomes(Anonymous class)
- which is just more consistent