v0.13.7
errors and warnings / stdlib

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

× failssrc/tracker.wowluawowlua
local function parse(text: string): number?    return tonumber(text)endexport function record(text: string)    print(parse(text))end
src/main.wowluawowlua
import internal parse from "/tracker"print(parse("3"))
✓ compilessrc/tracker.wowluawowlua
local function parse(text: string): number?    return tonumber(text)endexport function record(text: string)    print(parse(text))end
tests/tracker.test.wowluawowlua
import test, expect from "wowlua:test"import internal parse from "/tracker" @test("parses numbers")local function parses()    expect(parse("3")).toBe(3)end

The 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
codemessage
E8108wowlua:test / wowlua:mock imported outside a test file

Offline

terminal
$ wowlua explain E8119
E8119 (error): import internal outside a test file

source on GitHub ↗