diff --git a/types/es6template/es6template-tests.ts b/types/es6template/es6template-tests.ts new file mode 100644 index 0000000000..dce1a8fc82 --- /dev/null +++ b/types/es6template/es6template-tests.ts @@ -0,0 +1,14 @@ +import es6template = require('es6template'); + +// This rule is disabled because the library uses ES6-looking template strings, but with normal strings. +/* tslint:disable:no-invalid-template-strings */ + +const test1 = es6template('foo ${bar} baz ${quux}', {bar: 'BAR', quux: 'QUUX'}); +const test2 = es6template.render('Hello ${place} and ${user.name}!', { + place: 'world', + user: { + name: 'Charlike' + } +}); +const fn = es6template.compile('Hello ${place} and ${user.name}!'); +const test3 = fn({place: 'world', user: {name: 'Charlike'}}); diff --git a/types/es6template/index.d.ts b/types/es6template/index.d.ts new file mode 100644 index 0000000000..77c547622f --- /dev/null +++ b/types/es6template/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for es6template 1.0 +// Project: https://github.com/zalmoxisus/es6-template +// Definitions by: Nathan Bierema +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Default { + render: (str: string, locals: Record) => string; + + // This rule is disabled because the caller of `compile()` knows what the type of the `locals` parameter should be when + // calling the `compile` function. + // tslint:disable-next-line:no-unnecessary-generics + compile: (str: string) => ((locals: Locals) => string); + (str: string, locals: Record): string; +} +declare const _default: Default; +export = _default; diff --git a/types/es6template/tsconfig.json b/types/es6template/tsconfig.json new file mode 100644 index 0000000000..8e7cdc2709 --- /dev/null +++ b/types/es6template/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "es6template-tests.ts" + ] +} diff --git a/types/es6template/tslint.json b/types/es6template/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/es6template/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }