Files
typebox/test/static/not.ts
glm-5.1 bd758c2342 Fork from @sinclair/typebox 0.34.49 as @alkdev/typebox
- Rename package from @sinclair/typebox to @alkdev/typebox
- Update author, repository, and homepage to alkdev
- Remove GitHub workflows, .vscode config, and branding assets
- Update all source, test, example, changelog, and task imports
- Update tsconfig.json path mappings
- Clean up readme header (remove upstream badges/branding)
2026-04-23 13:22:31 +00:00

27 lines
969 B
TypeScript

import { Expect } from './assert'
import { Type } from '@alkdev/typebox'
{
// -------------------------------------------------------------------------
// Issue: type T = number extends not number ? true : false // true
// type T = number extends unknown ? true : false // true
//
// TypeScript does not support type negation. The best TypeBox can do is
// treat "not" as "unknown". From this standpoint, the extends assignability
// check needs to return true for the following case to keep TypeBox aligned
// with TypeScript static inference.
// -------------------------------------------------------------------------
const A = Type.Number()
const B = Type.Not(Type.Number())
const T = Type.Extends(A, B, Type.Literal(true), Type.Literal(false))
Expect(T).ToStatic<true>()
}
{
const T = Type.Not(Type.Number())
Expect(T).ToStatic<unknown>()
}
{
const T = Type.Not(Type.Not(Type.Number()))
Expect(T).ToStatic<number>()
}