Skip to content

Commit

Permalink
fix: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Aug 3, 2021
1 parent f61e5d2 commit 87de678
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export type Args = Record<string, any>;
export type Blocks = Record<string, Compiler>;
export type Compiler = <T extends Args> (data?: T, blocks?: Blocks) => Promise<string>|string;

export type Compiler<T extends Args = Args> =
| ((data: T, blocks?: Blocks) => Promise<string>|string)
| ((data?: T) => Promise<string>|string)

export interface Options {
loose?: boolean;
Expand All @@ -12,6 +15,7 @@ export interface Options {
export function esc<T=unknown>(value: T): T|string;
export function transform(input: string, options?: Options & { format?: 'esm' | 'cjs' }): string;

export function compile(input: string, options?: Options & { async: true }): <T extends Args> (data: T) => Promise<string>;
export function compile(input: string, options?: Options & { async: false }): <T extends Args> (data: T) => string;
export function compile(input: string, options?: Options & { escape?: typeof esc; }): Compiler;
type CompileOptions = Options & { escape?: typeof esc };
export function compile(input: string, options?: CompileOptions & { async: true }): <T extends Args> (data?: T, blocks?: Blocks) => Promise<string>;
export function compile(input: string, options?: CompileOptions & { async?: false }): <T extends Args> (data?: T, blocks?: Blocks) => string;
export function compile(input: string, options?: CompileOptions): Compiler;

0 comments on commit 87de678

Please sign in to comment.