devtypes - v2.0.0
    Preparing search index...

    Type Alias AssertTypeStrong<T, D>

    AssertTypeStrong: D extends T ? T : ThrowErrorOnInstantiation<T>

    Assert that a type is strongly assignable to another type.

    Type Parameters

    • T extends D

      The inferred or concrete type to validate

    • D

      The expected destination type

    This is a strict compile-time check that T is exactly assignable to D. If T is not assignable to D, or if D is not assignable to T, this will produce a compiler error.

    Hack: This type uses recursive conditional types to force TypeScript to evaluate the types fully, causing an error to be thrown if the assertion fails.

    type A = AssertTypeStrong< true, true >;               // ✓
    type B = AssertTypeStrong< true, boolean >; // ✗ TS error
    type C = AssertTypeStrong< string, string | number >; // ✗ TS error