errors and warnings / names / W1036
W1036 warning
A module of an import cycle reads an export (or, with import internal, a file-level local) of a module of the cycle checked after it that has no type annotation (or a typeof type alias it has not reached): it is any there
- area
- names (x1xxx)
- fails the build
- with --deny-warnings
Two modules import each other (a cycle that only runs later, which is
allowed), and the one checked first reads an export of the other that has
no type annotation. The modules of a cycle are checked in source order, so
that export's type isn't known yet and reads as any there: mistakes in its
use go unnoticed. Annotate the export in its module (export local items: string[] = {}). The same applies to a typeof type alias of the later
module, and to file-level locals read through import internal in tests.
Example
import items from "./other"export function show() print(#items)endimport show from "./main"export local items = {}export function add(name: string) table.insert(items, name) show()endimport items from "./other"export function show() print(#items)endimport show from "./main"export local items: string[] = {}export function add(name: string) table.insert(items, name) show()endThe compiler reports it like this:
warning[W1036]: `items` is `any` here: `other` is checked after this module in their import cycle, and its export `items` has no type annotation ┌─ src/main.wowlua:1:8 │ 1 │ import items from "./other" │ ^^^^^ read as `any` │ = help: annotate it where `other` exports it (`export local items: T = …`)
Related codes
| code | message |
|---|---|
| E1014 | Import or usage cycle containing a load-time edge (run-time-only cycles are allowed) |
Offline
$ wowlua explain W1036 W1036 (warning): A module of an import cycle reads an export (or, with import internal, a file-level local) of a module of the cycle checked after it that has no type annotation (or a typeof type alias it has not reached): it is any there