Reputation: 65870
Any clue to declare object inside the environment.ts
file? I have tried as shown below. But it doesn't detect the HotelEnvironment
interface?
export const environment = {
production: false,
/*hotelEnvironment:HotelEnvironment={
apiUrl: "",
titanUrl: "",
hotelName: ""
}*/
hotelEnvironment:HotelEnvironment={
apiUrl: "",
titanUrl: "",
hotelName: ""
}
};
export interface HotelEnvironment {
apiUrl: string;
titanUrl: string;
hotelName: string;
}
'HotelEnvironment' only refers to a type, but is being used as a value here.ts(2693)
Update:
I need to declare 2 or more hotel environments. i.e. I will have many hotels. But 1 hotel will appear once on the environment file. When we deploy the app, dev needs to comment out other hotels and enable only 1. My idea here was to minimize the errors dev will do when commented out the code. i.e. If I have 3 lines of code instead of a single object then dev may be commented out 2 lines and other will be missing and stay as uncommented. That will lead to unexpected behavior of the app.
Upvotes: 2
Views: 767
Reputation: 4340
Your export const environment
declares an simple json object.
Inside an object assignment, you cannot declare attribute type with :
but just a value.
You could try with the following snippet but not sure it will work
export const environment: {production: boolean, hotelEnvironment: HotelEnvironment} = {
production: false,
hotelEnvironment:{
apiUrl: "",
titanUrl: "",
hotelName: ""
}
};
export interface HotelEnvironment {
apiUrl: string;
titanUrl: string;
hotelName: string;
}
Upvotes: 3