-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
🔎 Search Terms
"string|String" primitive object collapse
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
function foo( message: unknown ) {
if (
( ! ( message instanceof String ) && typeof message !== 'string' ) ||
! /abcd/.test( message )
) {
}
}🙁 Actual behavior
Argument of type 'string | String' is not assignable to parameter of type 'string'.
Type 'String' is not assignable to type 'string'.
'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
🙂 Expected behavior
No error, should be collapsed, since String can be used as string in .test()
Additional information about the issue
Maybe related to #22617 ?
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created