diff --git a/types/handlebars-helpers/handlebars-helpers-tests.ts b/types/handlebars-helpers/handlebars-helpers-tests.ts new file mode 100644 index 0000000000..c03ac56fd4 --- /dev/null +++ b/types/handlebars-helpers/handlebars-helpers-tests.ts @@ -0,0 +1,11 @@ +import * as Handlebars from 'handlebars'; +import * as helpers from 'handlebars-helpers'; + +const handlebars = Handlebars.create(); + +helpers(); +helpers('helper'); +helpers(['helper']); +helpers({handlebars}); +helpers('helper', {handlebars}); +helpers(['helper'], {handlebars}); diff --git a/types/handlebars-helpers/index.d.ts b/types/handlebars-helpers/index.d.ts new file mode 100644 index 0000000000..5a1de16bef --- /dev/null +++ b/types/handlebars-helpers/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for handlebars-helpers 0.5 +// Project: http://assemble.io/helpers/ +// Definitions by: Toilal +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as Handlebars from 'handlebars'; + +declare function helpers(groups?: helpers.Options | string | string[], options?: helpers.Options): { [name: string]: Handlebars.HelperDelegate }; + +interface Utils { + /** + * Returns true if the given value contains the given + * `object`, optionally passing a starting index. + */ + contains(val: T[], obj: T, start: number): boolean; + + /** + * Remove leading and trailing whitespace and non-word + * characters from the given string. + */ + chop(str: string): string; + + /** + * Change casing on the given `string`, optionally + * passing a delimiter to use between words in the + * returned string. + * + * ```handlebars + * utils.changecase('fooBarBaz'); + * //=> 'foo bar baz' + * + * utils.changecase('fooBarBaz' '-'); + * //=> 'foo-bar-baz' + * ``` + */ + changecase(str: string, fn: (str: string) => string): string; +} + +declare namespace helpers { + interface Options { + handlebars?: typeof Handlebars; + hbs?: typeof Handlebars; + } + + const utils: Utils; +} + +export = helpers; diff --git a/types/handlebars-helpers/tsconfig.json b/types/handlebars-helpers/tsconfig.json new file mode 100644 index 0000000000..e822854459 --- /dev/null +++ b/types/handlebars-helpers/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "handlebars-helpers-tests.ts" + ] +} diff --git a/types/handlebars-helpers/tslint.json b/types/handlebars-helpers/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/handlebars-helpers/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}