4.0.4 • Published 6 months ago
@types/postcss-js v4.0.4
Installation
npm install --save @types/postcss-js
Summary
This package contains type definitions for postcss-js (https://github.com/postcss/postcss-js).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/postcss-js.
index.d.ts
// Type definitions for postcss-js 4.0
// Project: https://github.com/postcss/postcss-js
// Definitions by: Adam Thompson-Sharpe <https://github.com/MysteryBlokHed>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { AcceptedPlugin, ProcessOptions, Root, LazyResult } from 'postcss';
import NoWorkResult from 'postcss/lib/no-work-result';
/** CSS-in-JS object */
export type CssInJs = Record<string, any>;
/**
* Convert a PostCSS `Root` into a CSS-in-JS object
* @param root The root to convert
* @returns CSS-in-JS object
*/
export function objectify(root: Root): CssInJs;
/**
* Parse a CSS-in-JS object into a PostCSS `Root`
* @param obj The CSS-in-JS to parse
* @returns A PostCSS `Root`
*/
export function parse(obj: CssInJs): Root;
/**
* Create a PostCSS processor with a simple API
* @param plugins Synchronous plugins to use with PostCSS
* @returns A processor function that accepts (idk) and returns a CSS-in-JS object
*/
export function sync(plugins: AcceptedPlugin[]): (input: CssInJs) => CssInJs;
/**
* Create a PostCSS processor with a simple API, allowing asynchronous plugins
* @param plugins Plugins to use with PostCSS
* @returns A processor function that accepts (idk) and returns a CSS-in-JS object
*/
export function async(plugins: AcceptedPlugin[]): (input: CssInJs) => Promise<CssInJs>;
// Override process method to allow passing CssInJs
// when the parser is the postcss-js parser.
// This lets the postcss-js parser be used
// as long as the object passed to `process` is a CSS-in-JS object
declare module 'postcss/lib/processor' {
export default interface Processor {
process(
obj: CssInJs,
opts: Omit<ProcessOptions, 'parser'> & { parser: typeof parse },
): LazyResult | NoWorkResult;
}
}
Additional Details
- Last updated: Fri, 15 Apr 2022 00:01:31 GMT
- Dependencies: @types/postcss
- Global values: none
Credits
These definitions were written by Adam Thompson-Sharpe.