Merge pull request #28119 from tyler-johnson/nunjucks-fixes

add missing typings for nunjucks
This commit is contained in:
Benjamin Lichtman
2018-08-17 10:00:55 -07:00
committed by GitHub
3 changed files with 17 additions and 3 deletions
+13 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for nunjucks 3.0
// Type definitions for nunjucks 3.1
// Project: http://mozilla.github.io/nunjucks/
// Definitions by: Ruben Slabbert <https://github.com/RubenSlabbert>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -95,6 +95,7 @@ export function installJinjaCompat(): void;
export interface ILoader {
async?: boolean;
getSource(name: string): LoaderSource;
getSource(name: string, callback: (err?: any, result?: LoaderSource) => void): void;
extend?(extender: ILoader): ILoader;
}
@@ -128,7 +129,7 @@ export class FileSystemLoader extends Loader implements ILoader {
constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions);
}
export class WebLoader implements ILoader {
export class WebLoader extends Loader implements ILoader {
constructor(baseUrl: string, opts?: any);
getSource(name: string): LoaderSource;
}
@@ -137,3 +138,13 @@ export class PrecompiledLoader extends Loader implements ILoader {
init(searchPaths: string[], opts: any): void;
getSource(name: string): LoaderSource;
}
export namespace runtime {
class SafeString {
constructor(val: string);
val: string;
length: number;
valueOf(): string;
toString(): string;
}
}
+2
View File
@@ -52,3 +52,5 @@ class MyLoader extends nunjucks.Loader implements nunjucks.ILoader {
}
env = new nunjucks.Environment(new MyLoader());
new nunjucks.runtime.SafeString("an unsafe string");
+2 -1
View File
@@ -1,6 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": false
"interface-name": false,
"no-unnecessary-class": false // to allow SafeString class
}
}