Annotatedinterfaceno test imports itinterface AnnotatedWhatever carries annotations: every element.
| Member | Type | What it is |
|---|---|---|
annotations | readonly Annotation[] |
Annotations (commons data 0003-governance FR-007): a typed value of a kind that a vocabulary defines, on an element. A kind is made by annotationKind<T>(name, about) and says which kinds of element it may be on; annotate(kind, value) types the value by it, so that a value of another type does not compile; annotationsOf reads them back, typed. The kinds are open: a vocabulary an extension adds defines more, and nothing here knows them.
const synonym = annotationKind<string>("docs.synonym", ["concept", "attribute"]);
annotate(synonym, "client");Annotatedinterfaceno test imports itinterface AnnotatedWhatever carries annotations: every element.
| Member | Type | What it is |
|---|---|---|
annotations | readonly Annotation[] |
Annotationinterfaceinterface AnnotationAn annotation on an element: its kind, where that kind may be, and its value.
| Member | Type | What it is |
|---|---|---|
kind | `${string}.${string}` | |
about | readonly ElementKind[] | |
value | unknown |
AnnotationKindinterfaceno test imports itinterface AnnotationKind<T>A kind of annotation: its name, the kinds of element it may be on, and (for the compiler only) the type of its value.
| Member | Type | What it is |
|---|---|---|
name | `${string}.${string}` | |
about | readonly ElementKind[] | |
__value? | T | Never set: carries the type of the value, for the compiler. |
AnnotationNametypeno test imports ittype AnnotationName = `${string}.${string}`;The name of an annotation kind: a vocabulary, a dot and a name (privacy.personal).
annotatefunctionfunction annotate<T>(kind: AnnotationKind<T>, value: T): AnnotationAnnotates, typed by the kind: a value of another type does not compile.
| Parameter | What it is |
|---|---|
kind | the kind |
value | its value |
Returns: the annotation, frozen
annotationKindfunctionfunction annotationKind<T>(name: `${string}.${string}`, about: readonly ElementKind[]): AnnotationKind<T>Declares a kind of annotation.
| Parameter | What it is |
|---|---|
name | the vocabulary and the name, such as security.classification |
about | the kinds of element it may be on |
Returns: the kind, frozen
annotationsOffunctionfunction annotationsOf<T>(element: Annotated, kind: AnnotationKind<T>): readonly T[]The values of the annotations of a kind on an element, typed.
| Parameter | What it is |
|---|---|
element | the element |
kind | the kind |
Returns: the values, in the order they were written