From 779e53eb3bbc380e82ef1a95dc152a8c9199b83c Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Sun, 2 Oct 2016 17:06:55 -0700 Subject: [PATCH] Add typings for cssbeautify library (#11460) * Add typings for cssbeautify library * Don't paper over the fact that cssbeautify isn't ES module compatible. --- cssbeautify/cssbeautify-tests.ts | 13 +++++++++++++ cssbeautify/index.d.ts | 25 +++++++++++++++++++++++++ cssbeautify/tsconfig.json | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 cssbeautify/cssbeautify-tests.ts create mode 100644 cssbeautify/index.d.ts create mode 100644 cssbeautify/tsconfig.json diff --git a/cssbeautify/cssbeautify-tests.ts b/cssbeautify/cssbeautify-tests.ts new file mode 100644 index 0000000000..d68c713bad --- /dev/null +++ b/cssbeautify/cssbeautify-tests.ts @@ -0,0 +1,13 @@ +import cssbeautify = require('./index'); + +var str = ''; + +str = cssbeautify(str); + +str = cssbeautify(str, {}); + +str = cssbeautify(str, { + indent: ' ', + openbrace: 'separate-line', + autosemicolon: true +}); diff --git a/cssbeautify/index.d.ts b/cssbeautify/index.d.ts new file mode 100644 index 0000000000..e9c51dc88c --- /dev/null +++ b/cssbeautify/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for CSS Beautify v0.3.1 +// Project: https://github.com/senchalabs/cssbeautify +// Definitions by: rictic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Options { + /** + * A string used for the indentation of the declaration (default is 4 + * spaces). + */ + indent?: string; + /** + * Defines the placement of open curly brace, either end-of-line (default) + * or separate-line + */ + openbrace?: 'end-of-line'|'separate-line'; + + /** + * Always inserts a semicolon after the last ruleset(default is false) + */ + autosemicolon?: boolean; +} +declare function beautify(cssText: string, options?: Options): string; + +export = beautify; diff --git a/cssbeautify/tsconfig.json b/cssbeautify/tsconfig.json new file mode 100644 index 0000000000..a7b504a16b --- /dev/null +++ b/cssbeautify/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cssbeautify-tests.ts" + ] +}