mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
chore: fix types
This commit is contained in:
+2
-2
@@ -71,10 +71,10 @@ export class Liquid {
|
||||
return this.parser.parseFile(file, sync, LookupType.Layouts, currentFile)
|
||||
}
|
||||
public async parseFile (file: string): Promise<Template[]> {
|
||||
return toPromise(this.parser.parseFile(file, false))
|
||||
return toPromise<Template[]>(this.parser.parseFile(file, false))
|
||||
}
|
||||
public parseFileSync (file: string): Template[] {
|
||||
return toValue(this.parser.parseFile(file, true))
|
||||
return toValue<Template[]>(this.parser.parseFile(file, true))
|
||||
}
|
||||
public async renderFile (file: string, ctx?: object) {
|
||||
const templates = await this.parseFile(file)
|
||||
|
||||
@@ -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<Template[]>
|
||||
public parseFile: (file: string, sync?: boolean, type?: LookupType, currentFile?: string) => IterableIterator<any>
|
||||
|
||||
private liquid: Liquid
|
||||
private fs: FS
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ function isAsyncIterator (val: any): val is IterableIterator<any> {
|
||||
type Task<T> = Thenable<T>
|
||||
|
||||
// convert an async iterator to a thenable (Promise compatible)
|
||||
export function toThenable<T> (val: IterableIterator<T> | Thenable<T> | any): Thenable<T> {
|
||||
export function toThenable<T> (val: IterableIterator<any> | Thenable<T> | any): Thenable<T> {
|
||||
if (isThenable(val)) return val
|
||||
if (isAsyncIterator(val)) return reduce()
|
||||
return createResolvedThenable(val)
|
||||
@@ -64,12 +64,12 @@ export function toThenable<T> (val: IterableIterator<T> | Thenable<T> | any): Th
|
||||
}
|
||||
}
|
||||
|
||||
export function toPromise<T> (val: IterableIterator<T> | Thenable<T> | T): Promise<T> {
|
||||
export function toPromise<T> (val: IterableIterator<any> | Thenable<T> | T): Promise<T> {
|
||||
return Promise.resolve(toThenable(val))
|
||||
}
|
||||
|
||||
// get the value of async iterator in synchronous manner
|
||||
export function toValue<T> (val: IterableIterator<T> | Thenable<T> | T): T {
|
||||
export function toValue<T> (val: IterableIterator<any> | Thenable<T> | T): T {
|
||||
let ret: T
|
||||
toThenable(val)
|
||||
.then((x: any) => {
|
||||
|
||||
Reference in New Issue
Block a user