diff --git a/source/is-literal.d.ts b/source/is-literal.d.ts index 6f471dd22..262d4a61d 100644 --- a/source/is-literal.d.ts +++ b/source/is-literal.d.ts @@ -22,10 +22,12 @@ LiteralCheck<1, string> */ type LiteralCheck = ( IsNever extends false // Must be wider than `never` - ? [T] extends [LiteralType] // Must be narrower than `LiteralType` - ? [LiteralType] extends [T] // Cannot be wider than `LiteralType` - ? false - : true + ? [T] extends [LiteralType & infer U] // Remove any branding + ? [U] extends [LiteralType] // Must be narrower than `LiteralType` + ? [LiteralType] extends [U] // Cannot be wider than `LiteralType` + ? false + : true + : false : false : false ); diff --git a/test-d/is-literal.ts b/test-d/is-literal.ts index b37337368..fc67fd0bf 100644 --- a/test-d/is-literal.ts +++ b/test-d/is-literal.ts @@ -5,6 +5,7 @@ import type { IsNumericLiteral, IsBooleanLiteral, IsSymbolLiteral, + Tagged, } from '../index'; const stringLiteral = ''; @@ -65,3 +66,8 @@ type A2 = IsNumericLiteral; type A3 = IsBooleanLiteral; // @ts-expect-error type A4 = IsSymbolLiteral; + +// Tagged types should be false +expectType>>(false); +expectType>>(false); +expectType>>(false);