How can I refactor the following code so that I can simply import an object that implements a Typescript interface. I would like to get the following code down to a single line:
import configuration from './config';
let config: Configuration = configuration;
config.ts
const dev = {
backend: {
host: "https://localhost:5001"
}
}
const prod = {
backend: {
host: undefined
}
}
const config = process.env.REACT_APP_STAGE === 'production' ? prod : dev
// eslint-disable-next-line import/no-anonymous-default-export
export default {
...config
}
types.ts
export interface Configuration {
backend: BackendConfiguration
}
export interface BackendConfiguration {
host?: string
}