IF Commons GitHub

brand

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-core FR-001

Identifiers are types: a branded type is a plain value that the compiler keeps apart from others of the same shape, made only by the function that validates it (0001-core FR-001).

import type { Brand } from "./brand.ts";
type UserId = Brand<string, "UserId">;
const userId = (s: string): UserId | undefined => /^u[0-9]+$/.test(s) ? s as UserId : undefined;

Source: commons/core/src/brand.ts

1 of 1 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Brandtype
type Brand<T, B extends string> = T & { readonly "@ifc/brand": B };

A value of T that has been validated as a B; the brand exists only for the compiler and costs nothing at run time.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.