Greetings,
The type definition in this client is rudimental. Types in question:
import Config from './config';
import DefaultConfig from './default-config';
import VaultResponse from './vault-response';
export declare type VaultFunctionWithoutData = (path: string) => Promise<any>;
export declare type VaultFunctionWithData = (path: string, data: any) => Promise<any>;
export interface VaultFunc {
(config: Config): Promise<VaultResponse>;
create?: (defaultConfig: DefaultConfig) => VaultFunc;
read: VaultFunctionWithoutData;
list: VaultFunctionWithoutData;
delete: VaultFunctionWithoutData;
help: VaultFunctionWithoutData;
write: VaultFunctionWithData;
}
export default VaultFunc;
VaultFunc returns itself on create that one is just odd. While axios does something similar [Link] it returns an instance interface it extend from. Which brings me to. This also means that after returning an instance. You can STILL call create according to type definition...
- All vault function return the same interface. None of them are generic all of them return an
any promise. This will not play nice with strict checks and no implicit any configs.
create? is optional which makes it potentially undefined. As such I have to do vault.create?({ /* [...] */ }) to avoid an error/warning. This feels awkward.
Greetings,
The type definition in this client is rudimental. Types in question:
VaultFuncreturns itself oncreatethat one is just odd. While axios does something similar [Link] it returns an instance interface it extend from. Which brings me to. This also means that after returning an instance. You can STILL call create according to type definition...anypromise. This will not play nice with strict checks and no implicit any configs.create?is optional which makes it potentially undefined. As such I have to dovault.create?({ /* [...] */ })to avoid an error/warning. This feels awkward.