diff --git a/src/liquid.ts b/src/liquid.ts index 46b463b0c..33d0bc4d6 100644 --- a/src/liquid.ts +++ b/src/liquid.ts @@ -71,10 +71,10 @@ export class Liquid { return this.parser.parseFile(file, sync, LookupType.Layouts, currentFile) } public async parseFile (file: string): Promise { - return toPromise(this.parser.parseFile(file, false)) + return toPromise(this.parser.parseFile(file, false)) } public parseFileSync (file: string): Template[] { - return toValue(this.parser.parseFile(file, true)) + return toValue(this.parser.parseFile(file, true)) } public async renderFile (file: string, ctx?: object) { const templates = await this.parseFile(file) diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 919b02783..4d0757ef4 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -14,7 +14,7 @@ import { FS } from '../fs/fs' import { toThenable, Thenable } from '../util/async' export default class Parser { - public parseFile: (file: string, sync?: boolean, type?: LookupType, currentFile?: string) => Iterator + public parseFile: (file: string, sync?: boolean, type?: LookupType, currentFile?: string) => IterableIterator private liquid: Liquid private fs: FS diff --git a/src/util/async.ts b/src/util/async.ts index 86afbf878..f61d5d368 100644 --- a/src/util/async.ts +++ b/src/util/async.ts @@ -37,7 +37,7 @@ function isAsyncIterator (val: any): val is IterableIterator { type Task = Thenable // convert an async iterator to a thenable (Promise compatible) -export function toThenable (val: IterableIterator | Thenable | any): Thenable { +export function toThenable (val: IterableIterator | Thenable | any): Thenable { if (isThenable(val)) return val if (isAsyncIterator(val)) return reduce() return createResolvedThenable(val) @@ -64,12 +64,12 @@ export function toThenable (val: IterableIterator | Thenable | any): Th } } -export function toPromise (val: IterableIterator | Thenable | T): Promise { +export function toPromise (val: IterableIterator | Thenable | T): Promise { return Promise.resolve(toThenable(val)) } // get the value of async iterator in synchronous manner -export function toValue (val: IterableIterator | Thenable | T): T { +export function toValue (val: IterableIterator | Thenable | T): T { let ret: T toThenable(val) .then((x: any) => {