I am currently working on enhancing the data types within the iam-policies npm package.
My main focus is on augmenting the ConditionKey type, or any other approach that can help me achieve the desired outcome.
Take a look at the types file of the package:
export declare type ConditionKey = string | number | boolean;
...
declare type Resolver = (data: ConditionKey, expected: ConditionKey) => boolean;
export interface ConditionResolver {
[key: string]: Resolver;
}
export interface Context {
[key: string]: ConditionKey | Context | string[] | number[];
}
Here's the content of my file iam-policies.d.ts
:
import { conditionResolvers } from './conditions';
import { ConditionMap, ConditionKey } from 'iam-policies/dist/src/types';
declare module 'iam-policies/dist/src/types' {
type Resolver = (data: any, expected: any) => boolean;
type ConditionResolver = {
[key in keyof typeof conditionResolvers]?: Resolver
}
export interface Context {
[key: string]: any;
}
}
I am encountering errors such as "Duplicate Identifier 'ConditionBlock'", "Duplicate string index signature." and others indicating that the 'data' and 'expected' parameters in my conditionResolvers cannot be of type 'Date'. The tsconfig file I am using is similar to the one provided in the NestJS Typescript Starter.
My goal is to enhance the type of parameters in the Resolver object and the overall type structure. The ConditionResolver
represents a collection of functions.