getAnnotation
Import from @varavel/vdl-plugin-sdk/utils/ir.
function getAnnotation(annotations, name): Annotation | undefined;
Returns the first annotation that matches the provided name.
Annotation names are compared exactly as stored in the IR, without adding or
removing an @ prefix.
Parameters
| Parameter | Type | Description |
|---|---|---|
annotations | Annotation[] | undefined | Annotation list to search. |
name | string | Annotation name to match. |
Returns
Annotation | undefined
The matching annotation, or undefined when it is not present.
Example
const annotation = getAnnotation(field.annotations, "deprecated");
// returns the first `deprecated` annotation or undefined