Typescript: How to export a variable

There are two different types of export, named and default.

You can have multiple named exports per module but only one default export.

For a named export you can try something like:

// ./file1.ts
const arr = [1,2,3];
export { arr };

Then to import you could use the original statement:

// ./file2.ts
import { arr } from "./file1";
console.log(arr.length); // 3

This will get around the need for arr.arr you mentioned.

How do pirates know that they are pirates?
They think, therefore they ARR!!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)