diff --git a/types/clean-css/clean-css-tests.ts b/types/clean-css/clean-css-tests.ts deleted file mode 100644 index 7333424f11..0000000000 --- a/types/clean-css/clean-css-tests.ts +++ /dev/null @@ -1,54 +0,0 @@ - -import * as CleanCSS from 'clean-css'; - -var source = 'a{font-weight:bold;}'; -var minified = new CleanCSS().minify(source).styles; - -var source = '@import url(http://path/to/remote/styles);'; -new CleanCSS().minify(source, function (error, minified) { - console.log(minified.styles); -}); - -const pathToOutputDirectory = 'path'; - -new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) - .minify(source, function (error, minified) { - // access minified.sourceMap for SourceMapGenerator object - // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details - // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI - console.log(minified.sourceMap); -}); - -const inputSourceMapAsString = 'input'; -new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) - .minify(source, inputSourceMapAsString, function (error, minified) { - // access minified.sourceMap to access SourceMapGenerator object - // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details - // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI - console.log(); -}); - -new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }).minify({ - 'path/to/source/1': { - styles: '...styles...', - sourceMap: '...source-map...' - }, - 'path/to/source/2': { - styles: '...styles...', - sourceMap: '...source-map...' - } -}, function (error, minified) { - // access minified.sourceMap as above - console.log(minified.sourceMap); -}); - -new CleanCSS().minify(['path/to/file/one', 'path/to/file/two']); - -new CleanCSS().minify({ - 'path/to/file/one': { - styles: 'contents of file one' - }, - 'path/to/file/two': { - styles: 'contents of file two' - } -}); diff --git a/types/clean-css/index.d.ts b/types/clean-css/index.d.ts index 9c32ba8396..b8b52086f6 100644 --- a/types/clean-css/index.d.ts +++ b/types/clean-css/index.d.ts @@ -13,17 +13,19 @@ declare namespace CleanCSS { */ interface Options { /** - * Controls compatibility mode used; defaults to ie10+ using `'*'` + * Controls compatibility mode used; defaults to ie10+ using `'*'`. + * Compatibility hash exposes the following properties: `colors`, `properties`, `selectors`, and `units` */ compatibility?: "*" | "ie9" | "ie8" | "ie7" | CompatibilityOptions; /** * Controls a function for handling remote requests; Defaults to the build in `loadRemoteResource` function */ - fetch?: (uri: string, inlineRequest: HttpRequestOptions | HttpsRequestOptions, inlineTimeout: number, callback: FetchCallback) => void; + fetch?: (uri: string, inlineRequest: HttpRequestOptions | HttpsRequestOptions, inlineTimeout: number, done: (message: string | number, body: string) => void) => void; /** - * Controls output CSS formatting; defaults to `false` + * Controls output CSS formatting; defaults to `false`. + * Format hash exposes the following properties: `breaks`, `breakWith`, `indentBy`, `indentWith`, `spaces`, and `wrapAt`. */ format?: "beautify" | "keep-breaks" | Format | false; @@ -50,7 +52,8 @@ declare namespace CleanCSS { inlineTimeout?: number; /** - * Controls optimization level used; defaults to `1` + * Controls optimization level used; defaults to `1`. + * Level hash exposes `1`, and `2`. */ level?: 0 | 1 | 2 | optimizationsOptions; @@ -98,12 +101,12 @@ declare namespace CleanCSS { /** * A list of errors raised */ - errors: Array; + errors: string[]; /** * A list of warnings raised */ - warnings: Array; + warnings: string[]; /** * Contains statistics on the minify process @@ -516,7 +519,7 @@ declare namespace CleanCSS { /** * Defines a callback for fine-grained property optimization; defaults to no-op */ - transform?: (propertyName: string, propertyValue: string, selector: string) => string; + transform?: (propertyName: string, propertyValue: string, selector?: string) => string; }, 2?: { /** @@ -602,7 +605,7 @@ declare namespace CleanCSS { type FetchCallback = (message: string | number, body: string) => void; /** - * + * Interface exposed when a new CleanCSS option is created */ interface Function)> { minify(sources: string | Array | Object, callback?: (error: any, output: T) => void): T; @@ -610,15 +613,17 @@ declare namespace CleanCSS { minify(sources: string | Array | Object, inputSourceMap?: string, callback?: (error: any, output: T) => void): T; } + /** + * Constructor interface for CleanCSS + */ interface Constructor { - new(options: CleanCSS.Options & { returnPromise?: false }): Function; new(options: CleanCSS.Options & { returnPromise: true }): Function>; - new(): Function; + new(options?: CleanCSS.Options): Function; } } /** - * + * Creates a new CleanCSS object */ declare const CleanCSS: CleanCSS.Constructor; diff --git a/types/clean-css/tsconfig.json b/types/clean-css/tsconfig.json index fe65b21c11..82e6284376 100644 --- a/types/clean-css/tsconfig.json +++ b/types/clean-css/tsconfig.json @@ -18,7 +18,6 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "clean-css-tests.ts" + "index.d.ts" ] } \ No newline at end of file