This site was created with notaku.so! ๐Ÿ”ฅ

Vals need to be exported

You might be running into an error that looks like this:
plain text
ImportValError: 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:
typescript
export 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:
typescript
let ok = true;
And youโ€™re running into this issue, just add an export keyword:
typescript
export let ok = true;
๐ŸŽ‰ย Thatโ€™ll work!
The same goes for functions:
typescript
function x() {}
Wonโ€™t work, but
typescript
export function x() {}
Will!
Share