Packages
moon
2.90.4
2.90.5
retired
2.90.4
2.90.3
2.90.2
2.90.1
2.90.0
2.89.4
2.89.1
2.89.0
2.88.0
2.87.11
2.87.10
2.87.9
2.87.8
2.87.7
2.87.6
2.87.5
2.87.4
2.87.3
2.87.2
2.87.1
2.87.0
2.86.1
2.86.0
2.85.1
2.85.0
2.84.0
2.83.0
2.82.0
2.81.4
2.81.3
2.81.2
2.81.1
2.81.0
2.80.2
2.80.1
2.80.0
2.79.13
2.79.12
2.79.11
2.79.10
2.79.9
2.79.8
2.79.7
2.79.6
2.79.5
2.79.4
2.79.3
2.79.2
2.79.1
2.79.0
2.78.4
2.78.3
2.78.2
2.78.1
2.78.0
2.77.0
2.76.5
2.76.4
2.76.3
2.76.2
2.76.1
2.76.0
2.75.0
2.74.1
2.74.0
2.73.8
2.73.7
2.73.6
2.73.5
2.73.4
2.73.3
2.73.2
2.73.1
2.73.0
2.72.5
2.72.4
2.72.3
2.72.2
2.72.1
2.72.0
2.71.1
2.71.0
2.70.0
2.69.2
2.69.1
2.69.0
2.68.11
2.68.10
Components-based design system written in elixir
Current section
Files
Jump to
Current section
Files
assets/node_modules/ts-interface-checker/dist/index.d.ts
import { ITypeSuite, TType } from "./types";
import { IErrorDetail } from "./util";
/**
* Export functions used to define interfaces.
*/
export { TArray, TEnumType, TEnumLiteral, TFunc, TIface, TLiteral, TName, TOptional, TParam, TParamList, TProp, TTuple, TType, TUnion, TIntersection, array, enumlit, enumtype, func, iface, lit, name, opt, param, tuple, union, intersection, BasicType, ITypeSuite, } from "./types";
export { VError, IErrorDetail } from './util';
export interface ICheckerSuite {
[name: string]: Checker;
}
/**
* Takes one of more type suites (e.g. a module generated by `ts-interface-builder`), and combines
* them into a suite of interface checkers. If a type is used by name, that name should be present
* among the passed-in type suites.
*
* The returned object maps type names to Checker objects.
*/
export declare function createCheckers(...typeSuite: ITypeSuite[]): ICheckerSuite;
/**
* Checker implements validation of objects, and also includes accessors to validate method calls.
* Checkers should be created using `createCheckers()`.
*/
export declare class Checker {
private suite;
private ttype;
private _path;
private props;
private checkerPlain;
private checkerStrict;
constructor(suite: ITypeSuite, ttype: TType, _path?: string);
/**
* Set the path to report in errors, instead of the default "value". (E.g. if the Checker is for
* a "person" interface, set path to "person" to report e.g. "person.name is not a string".)
*/
setReportedPath(path: string): void;
/**
* Check that the given value satisfies this checker's type, or throw Error.
*/
check(value: any): void;
/**
* A fast check for whether or not the given value satisfies this Checker's type. This returns
* true or false, does not produce an error message, and is fast both on success and on failure.
*/
test(value: any): boolean;
/**
* Returns an error object describing the errors if the given value does not satisfy this
* Checker's type, or null if it does.
*/
validate(value: any): IErrorDetail | null;
/**
* Check that the given value satisfies this checker's type strictly. This checks that objects
* and tuples have no extra members. Note that this prevents backward compatibility, so usually
* a plain check() is more appropriate.
*/
strictCheck(value: any): void;
/**
* A fast strict check for whether or not the given value satisfies this Checker's type. Returns
* true or false, does not produce an error message, and is fast both on success and on failure.
*/
strictTest(value: any): boolean;
/**
* Returns an error object describing the errors if the given value does not satisfy this
* Checker's type strictly, or null if it does.
*/
strictValidate(value: any): IErrorDetail | null;
/**
* If this checker is for an interface, returns a Checker for the type required for the given
* property of this interface.
*/
getProp(prop: string): Checker;
/**
* If this checker is for an interface, returns a Checker for the argument-list required to call
* the given method of this interface. E.g. if this Checker is for the interface:
* interface Foo {
* find(s: string, pos?: number): number;
* }
* Then methodArgs("find").check(...) will succeed for ["foo"] and ["foo", 3], but not for [17].
*/
methodArgs(methodName: string): Checker;
/**
* If this checker is for an interface, returns a Checker for the return value of the given
* method of this interface.
*/
methodResult(methodName: string): Checker;
/**
* If this checker is for a function, returns a Checker for its argument-list.
*/
getArgs(): Checker;
/**
* If this checker is for a function, returns a Checker for its result.
*/
getResult(): Checker;
/**
* Return the type for which this is a checker.
*/
getType(): TType;
/**
* Actual implementation of check() and strictCheck().
*/
private _doCheck;
private _doValidate;
private _getMethod;
}
/**
* Typed checker interface. Adds type guard functionality to a normal `Checker`.
*
* To use, cast a `Checker` to a `CheckerT<>` using the appropriate type.
*
* eg.
* import { MyInterface } from './my-interface';
* import MyInterfaceTi from './my-interface-ti';
*
* const checkers = createCheckers(MyInterfaceTi) as {
* MyInterface: CheckerT<MyInterface>
* };
*
* TODO:
* - Enable `check()` and `strictCheck()` type assertion definitions once the functionality
* is correctly working in TypeScript. (https://github.com/microsoft/TypeScript/issues/36931)
*/
export interface CheckerT<T> extends Checker {
test(value: any): value is T;
strictTest(value: any): value is T;
}