# E4074

This error code is generated when a toplevel declaration is missing a necessary type annotation.
MoonBit requires toplevel variables and functions to have fully annotated types,
because types are important documentation for toplevel definitions.

There are two exceptions to this rule:

- if the value of a toplevel `let` is just a simple literal value, type annotation can be omitted:
    ```moonbit
    pub let forty_two = 42
    pub let float = 1.0
    pub let string = "Hello, world!"
    pub let array = [1, 2, 3]
    ```

- if the value is a private alias of a foreign value.
    In this case, the type can be easily inferred.
    However, for public `let`, MoonBit still requires annotation for documentation sake.

## Erroneous example

```{literalinclude} /sources/error_codes/4074_error/top.mbt
:language: moonbit
```

## Suggestion

This error can be fixed by explicitly annotating the type of the variable:

```{literalinclude} /sources/error_codes/4074_fixed/top.mbt
:language: moonbit
```
