mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Improve types for csso (#30607)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
09298b425d
commit
ec44d45205
@@ -15,7 +15,7 @@ csso.minify('.test { color: #ff0000; }', {
|
||||
logger: () => {}
|
||||
});
|
||||
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css; // $ExpectType string
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').map;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
sourceMap: true,
|
||||
@@ -27,14 +27,30 @@ csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
logger: () => {},
|
||||
usage: {
|
||||
tags: ['ul', 'li'],
|
||||
ids: ['x'],
|
||||
classes: ['a', 'b'],
|
||||
blacklist: {
|
||||
tags: ['body'],
|
||||
ids: ['y'],
|
||||
classes: ['c'],
|
||||
},
|
||||
scopes: [
|
||||
['a', 'b', 'c'],
|
||||
['d', 'e']
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
csso.compress({}).ast;
|
||||
csso.compress({}, {
|
||||
csso.compress({ type: 'CDC' }).ast; // $ExpectType CssNode
|
||||
csso.compress({ type: 'CDC' }, {
|
||||
restructure: false,
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
}).ast;
|
||||
}).ast; // $ExpectType CssNode
|
||||
|
||||
csso.syntax.parse('.b {font-weight: bold}'); // $ExpectType CssNode
|
||||
|
||||
23
types/csso/index.d.ts
vendored
23
types/csso/index.d.ts
vendored
@@ -1,8 +1,11 @@
|
||||
// Type definitions for csso 3.5
|
||||
// Project: https://github.com/css/csso
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Erik Källén <https://github.com/erik-kallen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import * as csstree from 'css-tree';
|
||||
|
||||
declare namespace csso {
|
||||
interface Result {
|
||||
@@ -16,6 +19,18 @@ declare namespace csso {
|
||||
map: object | null;
|
||||
}
|
||||
|
||||
interface Usage {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
scopes?: string[][];
|
||||
blacklist?: {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
interface CompressOptions {
|
||||
/**
|
||||
* Disable or enable a structure optimisations.
|
||||
@@ -44,7 +59,7 @@ declare namespace csso {
|
||||
/**
|
||||
* Usage data for advanced optimisations.
|
||||
*/
|
||||
usage?: object;
|
||||
usage?: Usage;
|
||||
/**
|
||||
* Function to track every step of transformation.
|
||||
*/
|
||||
@@ -100,7 +115,9 @@ interface Csso {
|
||||
/**
|
||||
* Does the main task – compress an AST.
|
||||
*/
|
||||
compress(ast: object, options?: csso.CompressOptions): { ast: object };
|
||||
compress(ast: csstree.CssNode, options?: csso.CompressOptions): { ast: csstree.CssNode };
|
||||
|
||||
syntax: typeof csstree;
|
||||
}
|
||||
|
||||
declare const csso: Csso;
|
||||
|
||||
Reference in New Issue
Block a user