Skip to content

Commit

Permalink
feat: infer nodecg instance & options defaults to any
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldszar committed Sep 7, 2020
1 parent 0a66e9d commit 2edb9cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ declare namespace Vault {
/**
* The vault option.
*/
interface Options<T> extends Omit<BaseOptions<T>, 'configName' | 'cwd' | 'projectName' | 'projectSuffix' | 'projectVersion'> {}
interface Options<T = any> extends Omit<BaseOptions<T>, 'configName' | 'cwd' | 'projectName' | 'projectSuffix' | 'projectVersion'> {}

/**
* A function returning the NodeCG instance and its vault.
*/
type Handler<T> = (nodecg: any, vault: Vault<T>) => void;
type Handler<T, V> = (nodecg: T, vault: Vault<V>) => void;
}

declare class Vault<T = any> extends Conf<T> {
declare class Vault<T = any, V = any> extends Conf<T> {
/**
* Creates a new vault.
* @param nodecg the NodeCG instance
* @param options this vault options
*/
constructor(nodecg: any, options?: Vault.Options<T>);
constructor(nodecg: T, options?: Vault.Options<V>);

/**
* Creates a wrapper returning the NodeCG instance and its vault.
* @param handler the handler
*/
static withVault<T = any>(handler: Vault.Handler<T>): void;
static withVault<T = any, V = any>(handler: Vault.Handler<T, V>): void;

/**
* Creates a wrapper returning the NodeCG instance and its vault.
* @param options this vault options
* @param handler the handler
*/
static withVault<T = any>(options: Vault.Options<T>, handler: Vault.Handler<T>): void;
static withVault<T = any, V = any>(options: Vault.Options<V>, handler: Vault.Handler<T, V>): void;
}

export = Vault;
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const nodecg = {
bundleVersion: '1.0.0'
};

expectType<Vault>(new Vault(nodecg));
expectType<Vault<typeof nodecg>>(new Vault(nodecg));

0 comments on commit 2edb9cc

Please sign in to comment.