diff --git a/types/twig/index.d.ts b/types/twig/index.d.ts index fcfb1806dd..04a3d1dbdf 100644 --- a/types/twig/index.d.ts +++ b/types/twig/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Carlos Ballesteros Velasco // Tim Schumacher // Maik Tizziani +// Daniel Melcer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/twig.d.ts @@ -24,6 +25,7 @@ export interface Parameters { export interface Template { reset(blocks: any): void; + render(context?: any, params?: any, allow_async?: false): string; render(context?: any, params?: any, allow_async?: boolean): string | Promise; renderAsync(context?: any, params?: any): Promise; importFile(file: string): Template; diff --git a/types/twig/twig-tests.ts b/types/twig/twig-tests.ts index 39fbdc804d..70cced0a99 100644 --- a/types/twig/twig-tests.ts +++ b/types/twig/twig-tests.ts @@ -20,6 +20,17 @@ const params: twig.Parameters = { const temp: twig.Template = twig.twig(params); +const result: string = temp.render(); + +const async_result: string | Promise = temp.render(undefined, undefined, true); + +function twig_async_param(b: boolean) { + const maybe_async_result: string | Promise = temp.render(undefined, undefined, b); +} + +twig_async_param(true); +twig_async_param(false); + const compOpts: twig.CompileOptions = { filename: str, settings: value