From ab7d7db1d2318619a8ebd8b6f1928c455b889892 Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 10:45:47 +0900 Subject: [PATCH 01/10] Activate unnecessarily ignored rules. --- types/nunjucks/tslint.json | 67 +------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index a41bf5d19a..f5f9eba608 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -1,79 +1,14 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, - "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, "strict-export-declare-modifiers": false, "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "unified-signatures": false } } From 41fb40bb68b666424d4188867da9fe319c8d3fca Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 10:48:01 +0900 Subject: [PATCH 02/10] cleanup ignore lint errors: no-consecutive-blank-lines, trim-file --- types/nunjucks/index.d.ts | 1 - types/nunjucks/nunjucks-tests.ts | 2 -- types/nunjucks/tslint.json | 2 -- 3 files changed, 5 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index 002f8b93f8..6a75cecd27 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace Nunjucks { function render(name: string, context?: Object): string; function render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; diff --git a/types/nunjucks/nunjucks-tests.ts b/types/nunjucks/nunjucks-tests.ts index 7407cc65ba..a1570fb301 100644 --- a/types/nunjucks/nunjucks-tests.ts +++ b/types/nunjucks/nunjucks-tests.ts @@ -1,7 +1,5 @@ - import nunjucks = require("nunjucks"); - nunjucks.configure({ autoescape: false }); let rendered = nunjucks.render("./noexists.html"); diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index f5f9eba608..2ff6c4ab8a 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -5,10 +5,8 @@ "dt-header": false, "export-just-namespace": false, "interface-name": false, - "no-consecutive-blank-lines": false, "prefer-const": false, "strict-export-declare-modifiers": false, - "trim-file": false, "unified-signatures": false } } From 8fc83723b33b0550ce61cbcb71e924f6e69cd60b Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 10:57:05 +0900 Subject: [PATCH 03/10] cleanup ignore lint error: unified-signatures --- types/nunjucks/index.d.ts | 9 ++------- types/nunjucks/tslint.json | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index 6a75cecd27..cf5cd6f5b4 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -10,7 +10,6 @@ declare namespace Nunjucks { function renderString(src: string, context: Object): string; function renderString(src: string, context: Object, callback?: (err: any, res: string) => any): void; - function compile(src: string, env?: Environment): Template; function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; function precompile(path: string, opts?: PrecompileOptions): string; @@ -33,8 +32,7 @@ declare namespace Nunjucks { } function configure(options: ConfigureOptions): Environment; - function configure(path: string, options?: ConfigureOptions): Environment; - function configure(path: string[], options?: ConfigureOptions): Environment; + function configure(path: string | string[], options?: ConfigureOptions): Environment; interface ConfigureOptions { autoescape?: boolean; @@ -63,10 +61,7 @@ declare namespace Nunjucks { autoescape: boolean; }; - constructor(); - constructor(loader: ILoader, opts?: ConfigureOptions); - constructor(loaders: ILoader[], opts?: ConfigureOptions); - + constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions); render(name: string, context?: Object): string; render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index 2ff6c4ab8a..a5b37cd1f8 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -6,7 +6,6 @@ "export-just-namespace": false, "interface-name": false, "prefer-const": false, - "strict-export-declare-modifiers": false, - "unified-signatures": false + "strict-export-declare-modifiers": false } } From e481e9ca2479c3cb853859814472eb74420603dc Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 10:59:06 +0900 Subject: [PATCH 04/10] cleanup ignore lint error: dt-header --- types/nunjucks/index.d.ts | 2 +- types/nunjucks/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index cf5cd6f5b4..a596aebecf 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for nunjucks +// Type definitions for nunjucks 3.0 // Project: http://mozilla.github.io/nunjucks/ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index a5b37cd1f8..c373dd4ad6 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "ban-types": false, - "dt-header": false, "export-just-namespace": false, "interface-name": false, "prefer-const": false, From f9293c661ffd0614265fe635807ca01808956854 Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:03:06 +0900 Subject: [PATCH 05/10] cleanup ignore lint error: prefer-const --- types/nunjucks/nunjucks-tests.ts | 8 ++++---- types/nunjucks/tslint.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/types/nunjucks/nunjucks-tests.ts b/types/nunjucks/nunjucks-tests.ts index a1570fb301..2d5888ce62 100644 --- a/types/nunjucks/nunjucks-tests.ts +++ b/types/nunjucks/nunjucks-tests.ts @@ -4,19 +4,19 @@ nunjucks.configure({ autoescape: false }); let rendered = nunjucks.render("./noexists.html"); -let ctx = { items: ["Hello", "this", "is", "for", "testing"] }; -let src = "{% for item in items %}{{item}}{% endfor %}"; +const ctx = { items: ["Hello", "this", "is", "for", "testing"] }; +const src = "{% for item in items %}{{item}}{% endfor %}"; rendered = nunjucks.renderString(src, ctx); -let compiled = nunjucks.compile(src); +const compiled = nunjucks.compile(src); rendered = compiled.render(ctx); rendered = nunjucks.precompileString(src, { name: "TestyWesty" }); -let template = new nunjucks.Template(src); +const template = new nunjucks.Template(src); rendered = template.render(ctx); let env = nunjucks.configure({ autoescape: false }); diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index c373dd4ad6..27c36c8561 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -4,7 +4,6 @@ "ban-types": false, "export-just-namespace": false, "interface-name": false, - "prefer-const": false, "strict-export-declare-modifiers": false } } From fb2435c3d4f82ab22d1627224ff9b117d42976fe Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:04:08 +0900 Subject: [PATCH 06/10] cleanup ignore lint error: strict-export-declare-modifiers --- types/nunjucks/index.d.ts | 2 +- types/nunjucks/tslint.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index a596aebecf..a710480bfc 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -128,7 +128,7 @@ declare namespace Nunjucks { constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); } - export class WebLoader implements ILoader { + class WebLoader implements ILoader { constructor(baseUrl: string, opts?: any); getSource(name: string): LoaderSource; } diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index 27c36c8561..546b9566c1 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -3,7 +3,6 @@ "rules": { "ban-types": false, "export-just-namespace": false, - "interface-name": false, - "strict-export-declare-modifiers": false + "interface-name": false } } From cdb226b3bacfe4fc542a00827db11434dce9fba1 Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:13:47 +0900 Subject: [PATCH 07/10] cleanup ignore lint error: export-just-namespace --- types/nunjucks/index.d.ts | 258 ++++++++++++++++++------------------- types/nunjucks/tslint.json | 1 - 2 files changed, 127 insertions(+), 132 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index a710480bfc..7cb6e22ccb 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -3,140 +3,136 @@ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace Nunjucks { - function render(name: string, context?: Object): string; - function render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; +export function render(name: string, context?: Object): string; +export function render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; - function renderString(src: string, context: Object): string; - function renderString(src: string, context: Object, callback?: (err: any, res: string) => any): void; +export function renderString(src: string, context: Object): string; +export function renderString(src: string, context: Object, callback?: (err: any, res: string) => any): void; - function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; +export function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; - function precompile(path: string, opts?: PrecompileOptions): string; - function precompileString(src: string, opts?: PrecompileOptions): string; +export function precompile(path: string, opts?: PrecompileOptions): string; +export function precompileString(src: string, opts?: PrecompileOptions): string; - interface PrecompileOptions { - name?: string; - asFunction?: boolean; - force?: boolean; - env?: Environment; - include?: string[]; - exclude?: string[]; - wrapper?(templates: { name: string, template: string }, opts: PrecompileOptions): string; - } - - class Template { - constructor(src: string, env?: Environment, eagerCompile?: boolean); - render(context?: Object): string; - render(context?: Object, callback?: (err: any, res: string) => any): void; - } - - function configure(options: ConfigureOptions): Environment; - function configure(path: string | string[], options?: ConfigureOptions): Environment; - - interface ConfigureOptions { - autoescape?: boolean; - throwOnUndefined?: boolean; - trimBlocks?: boolean; - lstripBlocks?: boolean; - watch?: boolean; - noCache?: boolean; - web?: { - useCache?: boolean, - async?: boolean - }; - express?: Object; - tags?: { - blockStart?: string, - blockEnd?: string, - variableStart?: string, - variableEnd?: string, - commentStart?: string, - commentEnd?: string - }; - } - - class Environment { - options: { - autoescape: boolean; - }; - - constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions); - render(name: string, context?: Object): string; - render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; - - renderString(name: string, context: Object): string; - renderString(name: string, context: Object, callback?: (err: any, res: string) => any): void; - - addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void; - getFilter(name: string): void; - - addExtension(name: string, ext: Extension): void; - removeExtension(name: string): void; - getExtension(name: string): Extension; - hasExtension(name: string): void; - - addGlobal(name: string, value: any): void; - - getTemplate(name: string, eagerCompile?: boolean): Template; - getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void; - - express(app: Object): void; - } - - interface Extension { - tags: string[]; - // Parser API is undocumented it is suggested to check the source: https://github.com/mozilla/nunjucks/blob/master/src/parser.js - parse(parser: any, nodes: any, lexer: any): any; - } - - function installJinjaCompat(): void; - - interface ILoader { - async?: boolean; - getSource(name: string): LoaderSource; - extend?(extender: ILoader): ILoader; - } - - // Needs both Loader and ILoader since nunjucks uses a custom object system - // Object system is also responsible for the extend methods - class Loader { - on(name: string, func: (...args: any[]) => any): void; - emit(name: string, ...args: any[]): void; - resolve(from: string, to: string): string; - isRelative(filename: string): boolean; - extend(toExtend: ILoader): ILoader; - } - - interface LoaderSource { - src: string; - path: string; - noCache: boolean; - } - - interface FileSystemLoaderOptions { - /** if true, the system will automatically update templates when they are changed on the filesystem */ - watch?: boolean; - - /** if true, the system will avoid using a cache and templates will be recompiled every single time */ - noCache?: boolean; - } - - class FileSystemLoader extends Loader implements ILoader { - init(searchPaths: string[], opts: any): void; - getSource(name: string): LoaderSource; - constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); - } - - class WebLoader implements ILoader { - constructor(baseUrl: string, opts?: any); - getSource(name: string): LoaderSource; - } - - class PrecompiledLoader extends Loader implements ILoader { - init(searchPaths: string[], opts: any): void; - getSource(name: string): LoaderSource; - } +export interface PrecompileOptions { + name?: string; + asFunction?: boolean; + force?: boolean; + env?: Environment; + include?: string[]; + exclude?: string[]; + wrapper?(templates: { name: string, template: string }, opts: PrecompileOptions): string; } -export = Nunjucks; +export class Template { + constructor(src: string, env?: Environment, eagerCompile?: boolean); + render(context?: Object): string; + render(context?: Object, callback?: (err: any, res: string) => any): void; +} + +export function configure(options: ConfigureOptions): Environment; +export function configure(path: string | string[], options?: ConfigureOptions): Environment; + +export interface ConfigureOptions { + autoescape?: boolean; + throwOnUndefined?: boolean; + trimBlocks?: boolean; + lstripBlocks?: boolean; + watch?: boolean; + noCache?: boolean; + web?: { + useCache?: boolean, + async?: boolean + }; + express?: Object; + tags?: { + blockStart?: string, + blockEnd?: string, + variableStart?: string, + variableEnd?: string, + commentStart?: string, + commentEnd?: string + }; +} + +export class Environment { + options: { + autoescape: boolean; + }; + + constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions); + render(name: string, context?: Object): string; + render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; + + renderString(name: string, context: Object): string; + renderString(name: string, context: Object, callback?: (err: any, res: string) => any): void; + + addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void; + getFilter(name: string): void; + + addExtension(name: string, ext: Extension): void; + removeExtension(name: string): void; + getExtension(name: string): Extension; + hasExtension(name: string): void; + + addGlobal(name: string, value: any): void; + + getTemplate(name: string, eagerCompile?: boolean): Template; + getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void; + + express(app: Object): void; +} + +export interface Extension { + tags: string[]; + // Parser API is undocumented it is suggested to check the source: https://github.com/mozilla/nunjucks/blob/master/src/parser.js + parse(parser: any, nodes: any, lexer: any): any; +} + +export function installJinjaCompat(): void; + +export interface ILoader { + async?: boolean; + getSource(name: string): LoaderSource; + extend?(extender: ILoader): ILoader; +} + +// Needs both Loader and ILoader since nunjucks uses a custom object system +// Object system is also responsible for the extend methods +export class Loader { + on(name: string, func: (...args: any[]) => any): void; + emit(name: string, ...args: any[]): void; + resolve(from: string, to: string): string; + isRelative(filename: string): boolean; + extend(toExtend: ILoader): ILoader; +} + +export interface LoaderSource { + src: string; + path: string; + noCache: boolean; +} + +export interface FileSystemLoaderOptions { + /** if true, the system will automatically update templates when they are changed on the filesystem */ + watch?: boolean; + + /** if true, the system will avoid using a cache and templates will be recompiled every single time */ + noCache?: boolean; +} + +export class FileSystemLoader extends Loader implements ILoader { + init(searchPaths: string[], opts: any): void; + getSource(name: string): LoaderSource; + constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); +} + +export class WebLoader implements ILoader { + constructor(baseUrl: string, opts?: any); + getSource(name: string): LoaderSource; +} + +export class PrecompiledLoader extends Loader implements ILoader { + init(searchPaths: string[], opts: any): void; + getSource(name: string): LoaderSource; +} diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index 546b9566c1..d2ed987c9e 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "ban-types": false, - "export-just-namespace": false, "interface-name": false } } From 7019fca21631502712e2dad282bc1574a82da11b Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:17:39 +0900 Subject: [PATCH 08/10] cleanup ignore lint error: ban-types --- types/nunjucks/index.d.ts | 25 +++++++++++++------------ types/nunjucks/tslint.json | 1 - 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index 7cb6e22ccb..e8e654a1de 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -2,12 +2,13 @@ // Project: http://mozilla.github.io/nunjucks/ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -export function render(name: string, context?: Object): string; -export function render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; +export function render(name: string, context?: object): string; +export function render(name: string, context?: object, callback?: (err: any, res: string) => any): void; -export function renderString(src: string, context: Object): string; -export function renderString(src: string, context: Object, callback?: (err: any, res: string) => any): void; +export function renderString(src: string, context: object): string; +export function renderString(src: string, context: object, callback?: (err: any, res: string) => any): void; export function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; @@ -26,8 +27,8 @@ export interface PrecompileOptions { export class Template { constructor(src: string, env?: Environment, eagerCompile?: boolean); - render(context?: Object): string; - render(context?: Object, callback?: (err: any, res: string) => any): void; + render(context?: object): string; + render(context?: object, callback?: (err: any, res: string) => any): void; } export function configure(options: ConfigureOptions): Environment; @@ -44,7 +45,7 @@ export interface ConfigureOptions { useCache?: boolean, async?: boolean }; - express?: Object; + express?: object; tags?: { blockStart?: string, blockEnd?: string, @@ -61,11 +62,11 @@ export class Environment { }; constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions); - render(name: string, context?: Object): string; - render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; + render(name: string, context?: object): string; + render(name: string, context?: object, callback?: (err: any, res: string) => any): void; - renderString(name: string, context: Object): string; - renderString(name: string, context: Object, callback?: (err: any, res: string) => any): void; + renderString(name: string, context: object): string; + renderString(name: string, context: object, callback?: (err: any, res: string) => any): void; addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void; getFilter(name: string): void; @@ -80,7 +81,7 @@ export class Environment { getTemplate(name: string, eagerCompile?: boolean): Template; getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void; - express(app: Object): void; + express(app: object): void; } export interface Extension { diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index d2ed987c9e..2c7c1bed53 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false, "interface-name": false } } From ef7fa932c6a9db43f2913516337bf9aa33cb0b84 Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:42:37 +0900 Subject: [PATCH 09/10] Enable strictNullCheck (See: https://mozilla.github.io/nunjucks/api.html#constructor) --- types/nunjucks/index.d.ts | 2 +- types/nunjucks/tsconfig.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index e8e654a1de..d307bd27d5 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -61,7 +61,7 @@ export class Environment { autoescape: boolean; }; - constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions); + constructor(loader?: ILoader | ILoader[] | null, opts?: ConfigureOptions); render(name: string, context?: object): string; render(name: string, context?: object, callback?: (err: any, res: string) => any): void; diff --git a/types/nunjucks/tsconfig.json b/types/nunjucks/tsconfig.json index 39cf9bfbca..5824ce2f1f 100644 --- a/types/nunjucks/tsconfig.json +++ b/types/nunjucks/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "nunjucks-tests.ts" ] -} \ No newline at end of file +} From 86928c2c5fbefded577edbbd79bc0914af92200b Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 7 Nov 2017 11:44:55 +0900 Subject: [PATCH 10/10] add test --- types/nunjucks/nunjucks-tests.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/nunjucks/nunjucks-tests.ts b/types/nunjucks/nunjucks-tests.ts index 2d5888ce62..9f3afcddfe 100644 --- a/types/nunjucks/nunjucks-tests.ts +++ b/types/nunjucks/nunjucks-tests.ts @@ -4,13 +4,18 @@ nunjucks.configure({ autoescape: false }); let rendered = nunjucks.render("./noexists.html"); +nunjucks.render('foo.html', { username: 'James' }); +nunjucks.render('async.html', (err: any, res: string) => {}); + const ctx = { items: ["Hello", "this", "is", "for", "testing"] }; const src = "{% for item in items %}{{item}}{% endfor %}"; rendered = nunjucks.renderString(src, ctx); +nunjucks.renderString('Hello {{ username }}', { username: 'James' }); const compiled = nunjucks.compile(src); rendered = compiled.render(ctx); +nunjucks.compile('Hello {{ username }}').render({ username: 'James' }); rendered = nunjucks.precompileString(src, { name: "TestyWesty" @@ -20,6 +25,11 @@ const template = new nunjucks.Template(src); rendered = template.render(ctx); let env = nunjucks.configure({ autoescape: false }); +nunjucks.configure('/views'); +nunjucks.configure('views', { + autoescape: true, + watch: true +}); rendered = env.renderString(src, ctx); env.addExtension("SpawnGlitter", {