Annotations

Annotations

> LeekScript

There are currently 7 annotations. They can be placed in front of a function or a method to provide additional information. They also apply to local variables, global variables and classes. In the editor, the documentation of each annotation is shown on hover.

How to use annotations?

To use an annotation, you can write:

or

Annotations can also be combined:

Existing annotations

@deprecated

A function or method annotated with @deprecated shows a warning at compile time when it is called. This indicates that the function should no longer be used and will be removed later.

For example:

@todo

A function or method annotated with @todo inserts a todo-type warning at compile time to indicate that it is not complete.

@unused

A function or method annotated with @unused will not emit a warning if it is not used. This is particularly useful in strict mode if the function is implemented but the code does not call it.

For example:

Note: prefixing a name with _ (for example var _resultat) already suppresses the "not used" warning, without any annotation.

@nodiscard

A function or method annotated with @nodiscard will show a warning if its return value is not used.

@pure

Currently, @pure has the same effect as @nodiscard. However, @pure implies more:

A pure function must not mutate state and must not have side effects. That is, it must not modify variables outside its scope, and must be deterministic (no random).

@override

A method annotated with @override tells the developer that it changes the implementation of a method of the parent class.

For example:

@tailrec

A function or method annotated with @tailrec indicates that it is tail recursive: this means the function is recursive and the recursive call is the last instruction of the function.

This annotation may be useful to the compiler but is currently never used.