I have the following interface in TypeScript:
interface IX {
a: string,
b: any,
c: AnotherType
}
I declare a variable of that t
My solution:
I have created wrapper over Object.assign to fix typing issues.
export function assign(...args: T[] | Partial[]): T {
return Object.assign.apply(Object, [{}, ...args]);
}
Usage:
env.base.ts
export interface EnvironmentValues {
export interface EnvironmentValues {
isBrowser: boolean;
apiURL: string;
}
export const enviromentBaseValues: Partial = {
isBrowser: typeof window !== 'undefined',
};
export default enviromentBaseValues;
env.dev.ts
import { EnvironmentValues, enviromentBaseValues } from './env.base';
import { assign } from '../utilities';
export const enviromentDevValues: EnvironmentValues = assign(
{
apiURL: '/api',
},
enviromentBaseValues
);
export default enviromentDevValues;