• Version 0.0.2
  • Published
  • 3.43 kB
  • 1 dependency
  • MIT license


npm i typescript-compare
yarn add typescript-compare
pnpm add typescript-compare


TypeScript generics to compare types


Type Aliases

type Any

type Any<Type> = And<prv.Extends<Type, 0>, prv.Extends<Type, 1>>;

    type Compare

    type Compare<A, B, Options extends Compare.Options = Compare.Options.Default> = If<
    Extends<A, B>,
    Extends<B, A>,
    Options['equal' | 'broaderRight' | 'broaderLeft'],
    If<Extends<B, A>, Options['broaderLeft'], Options['mismatch']>

      type Equal

      type Equal<A, B> = Or<
      And<Any<A>, Any<B>>,
      And<And<NotAny<A>, NotAny<B>>, And<Extends<A, B>, Extends<B, A>>>

        type Extends

        type Extends<A, B> = Or<Any<B>, If<Any<A>, Any<B>, prv.Extends<A, B>>>;

          type NotAny

          type NotAny<Type, True = true, False = true> = Not<Any<Type>>;

            type NotEqual

            type NotEqual<A, B> = Not<Equal<A, B>>;


              namespace Compare

              namespace Compare {}

                interface Options

                interface Options {}

                  property broaderLeft

                  broaderLeft: any;

                    property broaderRight

                    broaderRight: any;

                      property equal

                      equal: any;

                        property mismatch

                        mismatch: any;

                          type Strict

                          type Strict<A, B, Options extends Compare.Options = Compare.Options.Default> = If<
                          Extends<A, B>,
                          If<Extends<B, A>, Options['equal'], Options['broaderRight']>,
                          If<Extends<B, A>, Options['broaderLeft'], Options['mismatch']>

                            namespace Compare.Options

                            namespace Compare.Options {}

                              interface Default

                              interface Default extends Compare.Options {}

                                property broaderLeft

                                broaderLeft: 'broaderLeft';

                                  property broaderRight

                                  broaderRight: 'broaderRight';

                                    property equal

                                    equal: 'equal';

                                      property mismatch

                                      mismatch: 'mismatch';

                                        namespace prv

                                        namespace prv {}

                                          type Extends

                                          type Extends<A, B> = [A] extends [B] ? true : false;

                                            Package Files (1)

                                            Dependencies (1)

                                            Dev Dependencies (2)

                                            Peer Dependencies (0)

                                            No peer dependencies.


                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/typescript-compare.

                                            • Markdown
                                            • HTML
                                              <a href="https://www.jsdocs.io/package/typescript-compare"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>