Hey everyone, I was under the impression that it should be possible to import TypeScript files into Astro components, right? I can import TypeScript/JSX/React-components, but somehow a pure Typescript file does not work for me.
This is the file I'm trying to import:
interface ILanguage {
locale: string;
name: string;
}
export const LANGUAGES: Array<ILanguage> = [
{
locale: "de",
name: "Deutsch",
},
{
locale: "en",
name: "English",
}
];
And this is my import:
---
import { LANGUAGES } from "@config";
const allLocales = LANGUAGES.map(language => language.locale);
---
Yet, I am only getting this:
error allLocales is not defined
Hint:
export statements in `.astro` files do not have access to local variable declarations, only imported values.
Code:
> 1 | ---
| ^
2 | import { LANGUAGES } from "@config";
4 | const allLocales = LANGUAGES.map(language => language.locale);