Skip to main content
Module

x/cliffy/dev_deps.ts>assertType

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Latest
function assertType
import { assertType } from "https://deno.land/x/cliffy@v1.0.0-rc.4/dev_deps.ts";

Asserts at compile time that the provided type argument's type resolves to the expected boolean literal type.

Examples

Example 1

import { assertType, IsExact, IsNullable } from "https://deno.land/std@0.224.0/testing/types.ts";

const result = "some result" as string | number;

// compile error if the type of `result` is not exactly `string | number`
assertType<IsExact<typeof result, string | number>>(true);

// causes a compile error that `true` is not assignable to `false`
assertType<IsNullable<string>>(true); // error: string is not nullable

Type Parameters

T extends true | false

Parameters

_expectTrue: T
  • True if the passed in type argument resolved to true.