You can solve this problem by using a getter for the faqs property. A getter lets you dynamically access the email value without encountering the issue of trying to use a variable before it’s been fully defined.
interface Config {
email: string;
faqs: Array<FAQ>;
}
export interface FAQ {
question: string;
answer: string;
}
export const config: Config = {
email: "[email protected]",
get faqs(): Array<FAQ> {
return [
{
question: "simple question",
answer: `I want to refer to ${this.email} here`,
},
];
},
};