-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add error message #10446
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
Add error message #10446
Conversation
Add error message when trying to relate primitives to the boxed/apparent backing types.
@@ -6258,6 +6258,13 @@ namespace ts { | |||
targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); | |||
} | |||
|
|||
// check if trying to relate primitives to the boxed/apparent backing types. | |||
if ((sourceType === "Number" && targetType === "number") || |
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.
You don't want to do this because you might be in a context where Number
has been shadowed to something else.
You also need to cover Symbol
/symbol
.
Instead, do a check against
globalStringType
/stringType
globalNumberType
/numberType
globalBooleanType
/booleanType
getGlobalESSymbolType()
/esSymbolType
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.
Also, I don't think you necessarily want to do this here. I think you want to have a separate function for this logic right before this line in isRelatedTo
:
if (reportErrors) {
reportRelationError(headMessage, source, target);
}
So before that, I'd have a check like
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) {
tryElaborateErrorsForPrimitivesAndObjects(source, target);
}
Looks like a nice improvement in the baselines! 😄 |
@DanielRosenwasser Thanks your kindfull advise. I have no idea why some tests fail. Do you have any ideas? |
Whoops - that's being caused by the assertion in if (reportErrors) {
// ...
} block in |
@DanielRosenwasser Nice 👍 I could resolve my issues. |
Nice job! @RyanCavanaugh and @sandersn, any feedback? |
The ES spec refers to these as "wrapper objects" and doesn't use the term "box". I would prefer something like
Thoughts? |
Let's go with Ryan's suggestion and I think we'll be good to pull in. |
change error message. |
Fixes #10351
Reference https://developer.mozilla.org/en-US/docs/Glossary/Primitive
Add error message when trying to relate primitives to the boxed/apparent backing types.