UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

67 lines (66 loc) 2.15 kB
import { Lazy } from './util/Lazy.js'; export type Hint = Hint.String | Hint.Number | Hint.Boolean | Hint.Array | Hint.Literal | Hint.Definition | Hint.Object | Hint.Union | Hint.Intersection | Hint.Extern; export declare namespace Hint { interface String { type: 'string'; } interface Number { type: 'number'; } interface Boolean { type: 'boolean'; } interface Array { type: 'array'; inner: Hint; } interface Literal { type: 'literal'; value: string; } interface Definition { type: 'definition'; name: string; fields: Lazy<Record<string, Hint>>; extend: Hint[]; } interface Object { type: 'object'; fields: Record<string, Hint>; } interface Union { type: 'union'; options: Hint[]; } interface Intersection { type: 'intersection'; options: Hint[]; } interface ExternLocation { name: string; package: string; } interface Extern { type: 'extern'; from: ExternLocation; typeParams: Hint[]; } interface TypeDefinition extends Definition { parents: string[]; } function String(): Hint.String; function Number(): Hint.Number; function Boolean(): Hint.Boolean; function Literal(value: string): Hint.Literal; function Array(inner: Hint): Hint.Array; function Definition(name: string, fields: Lazy<Record<string, Hint>>, ...extend: Hint[]): Hint; function Object(fields: Record<string, Hint>): Hint.Object; function Union(options: Hint[]): Hint.Union; function Intersection(...options: Hint[]): Hint.Intersection; function Extern(from: ExternLocation, ...typeParams: Hint[]): Hint.Extern; function isValidIdentifier(identifier: string): boolean; function isDefinitionName(identifier: string): boolean; function externs(hints: Hint[], map?: Map<string, Set<string>>): Map<string, Set<string>>; function definitions(hints: Hint[], parents?: string[]): Generator<TypeDefinition>; function equals(a: Hint, b: Hint): boolean; }