added definitions for icss-utils (#36052)

This commit is contained in:
Bob Matcuk 2019-06-13 20:15:21 -07:00 committed by Ron Buckton
parent 576fe4a44d
commit a6cda8a2df
5 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import { replaceValueSymbols, replaceSymbols, extractICSS, createICSSRules } from "icss-utils";
import postcss = require("postcss");
const root = postcss.parse("a#css.string { color: red }");
const replacements = {
quick: "slow",
lazy: "energetic",
};
const s: string = replaceValueSymbols("The quick brown fox jumps over the lazy dog.", replacements);
replaceSymbols(root, replacements);
const { icssImports, icssExports } = extractICSS(root);
const s2: string = icssImports.monkey.bagel;
const s3: string = icssExports.foo;
extractICSS(root, false);
const rules: postcss.Rule[] = createICSSRules(icssImports, icssExports);

32
types/icss-utils/index.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
// Type definitions for icss-utils 4.1
// Project: https://github.com/css-modules/icss-utils#readme
// Definitions by: Bob Matcuk <https://github.com/bmatcuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { Container, Rule } from "postcss";
export interface Replacements {
[key: string]: string;
}
export interface CSSImports {
[key: string]: { [key: string]: string };
}
export interface CSSExports {
[key: string]: string;
}
export interface ExtractedICSS {
icssImports: CSSImports;
icssExports: CSSExports;
}
export function replaceValueSymbols(value: string, replacements: Replacements): string;
export function replaceSymbols(css: Container, replacements: Replacements): void;
export function extractICSS(css: Container, removeRules?: boolean): ExtractedICSS;
export function createICSSRules(imports: CSSImports, exports: CSSExports): Rule[];

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"postcss": "^7.0.0"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"icss-utils-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }