-
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