This is an external interface definition which I'm importing into my file:
export interface WorkspaceJsonConfiguration {
version: number;
projects: {
[projectName: string]: ProjectConfiguration;
};
defaultProject?: string;
}
Now I need to extend ProjectConfiguration
by adding two fields:
import { WorkspaceJsonConfiguration, ProjectConfiguration } from '@nrwl/devkit'
interface ProjectConfig extends ProjectConfiguration {
version: string
date: string
}
But this seems to be wrong as it doesn't extend WorkspaceJsonConfiguration
, which I'm using in my file.
CodePudding user response:
It sounds like module augmentation and declaration merging is what you're looking for. It will allow you to augment the ProjectConfiguration
interface with your custom properties:
import { ProjectConfiguration } from '@nrwl/devkit'; // Don't forget this import
declare module '@nrwl/devkit' {
interface ProjectConfiguration {
version: string
date: string
}
}
Now when working with your WorkspaceJsonConfiguration
objects you'll notice that each project
will be prompted for the extra fields you augmented.