errors and warnings / stdlib / E8119
E8119 error
import internal outside a test file
- area
- stdlib (x8xxx)
- fails the build
- yes
A file of the addon uses import internal. import internal gives a file a
module's private locals and types, so that tests can test helpers without
exporting them. Only test files may use it, and addon builds stay unchanged.
In addon code, export what other files need and import it normally.
Example
local function parse(text: string): number? return tonumber(text)endexport function record(text: string) print(parse(text))endimport internal parse from "/tracker"print(parse("3"))local function parse(text: string): number? return tonumber(text)endexport function record(text: string) print(parse(text))endimport test, expect from "wowlua:test"import internal parse from "/tracker" @test("parses numbers")local function parses() expect(parse("3")).toBe(3)endThe compiler reports it like this:
error[E8119]: `import internal` is only for test files ┌─ src/main.wowlua:1:1 │ 1 │ import internal parse from "/tracker" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here │ = help: export what other files use
Related codes
| code | message |
|---|---|
| E8108 | wowlua:test / wowlua:mock imported outside a test file |
Offline
$ wowlua explain E8119 E8119 (error): import internal outside a test file