You might be running into an error that looks like this:
plain textImportValError: Vals require exactly one export. This val has none.
This is because vals need to have one export. In JavaScript, each file (or each val, in our case) can have exported variables and declarations. These values are exported with the
export
keyword, and are different from the rest of the variables because theyโre accessible to other files.For example, a web handler might look like:
typescriptexport async function okHandler(request: Request): Promise<Response> { return Response.json({ ok: 1 }); }
Which exports the
okHandler
method. So, if youโve got a val like this:typescriptlet ok = true;
And youโre running into this issue, just add an export keyword:
typescriptexport let ok = true;
๐ย Thatโll work!
The same goes for functions:
typescriptfunction x() {}
Wonโt work, but
typescriptexport function x() {}
Will!