I'm working with angular-gridster2, which has an interface, GridsterConfig:
export interface GridsterConfig {
fixedColWidth?: number;
fixedRowHeight?: number;
...
[propName: string]: any;
}
The problem is, the propName allows any property to be added or referenced, allowing for typos to be ignored by the compiler. This compiles just fine:
let foo: GridsterConfig = {};
foo.doesnotexist = "OOPS";
I know that I can create a new interface with Pick:
type MyGridsterConfig1 = Pick<GridsterConfig, 'fixedColWidth' | 'fixedRowHeight'>;
let mgc1: MyGridsterConfig1 = {};
mgc1.doesnotexist = 100; // <-- compiler error
And can use Omit on explicit properties, but I haven't found a way to effectively do:
Omit<GridsterConfig, '[propName: string]'>.
The only thing I've found so far is to Pick all the properties (there's a number of them). Is there a better way to do this?