mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
added definitions for postcss-load-config (#36053)
This commit is contained in:
parent
0c112a5de1
commit
f396262330
47
types/postcss-load-config/index.d.ts
vendored
Normal file
47
types/postcss-load-config/index.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Type definitions for postcss-load-config 2.0
|
||||
// Project: https://github.com/michael-ciniawsky/postcss-load-config#readme
|
||||
// Definitions by: Bob Matcuk <https://github.com/bmatcuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Parser, Plugin, ProcessOptions, Processor, Stringifier, Syntax, Transformer } from "postcss";
|
||||
import cosmiconfig = require("cosmiconfig");
|
||||
|
||||
// In the ConfigContext, these three options can be instances of the
|
||||
// appropriate class, or strings. If they are strings, postcss-load-config will
|
||||
// require() them and pass the instances along.
|
||||
interface ProcessOptionsPreload {
|
||||
parser?: string | ProcessOptions['parser'];
|
||||
stringifier?: string | ProcessOptions['stringifier'];
|
||||
syntax?: string | ProcessOptions['syntax'];
|
||||
}
|
||||
|
||||
// The remaining ProcessOptions, sans the three above.
|
||||
type RemainingProcessOptions =
|
||||
Pick<ProcessOptions, Exclude<keyof ProcessOptions, keyof ProcessOptionsPreload>>;
|
||||
|
||||
// Additional context options that postcss-load-config understands.
|
||||
interface Context {
|
||||
cwd?: string;
|
||||
env?: string;
|
||||
}
|
||||
|
||||
// The full shape of the ConfigContext.
|
||||
type ConfigContext = Context & ProcessOptionsPreload & RemainingProcessOptions;
|
||||
|
||||
// Result of postcssrc is a Promise containing the filename plus the options
|
||||
// and plugins that are ready to pass on to postcss.
|
||||
type ResultPlugin = Plugin<any> | Transformer | Processor;
|
||||
interface Result {
|
||||
file: string;
|
||||
options: ProcessOptions;
|
||||
plugins: ResultPlugin[];
|
||||
}
|
||||
|
||||
declare function postcssrc(ctx?: ConfigContext, path?: string, options?: cosmiconfig.ExplorerOptions): Promise<Result>;
|
||||
|
||||
declare namespace postcssrc {
|
||||
function sync(ctx?: ConfigContext, path?: string, options?: cosmiconfig.ExplorerOptions): Result;
|
||||
}
|
||||
|
||||
export = postcssrc;
|
||||
6
types/postcss-load-config/package.json
Normal file
6
types/postcss-load-config/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"postcss": "^7.0.0"
|
||||
}
|
||||
}
|
||||
11
types/postcss-load-config/postcss-load-config-tests.ts
Normal file
11
types/postcss-load-config/postcss-load-config-tests.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import postcss = require("postcss");
|
||||
import postcssrc = require("postcss-load-config");
|
||||
|
||||
postcssrc();
|
||||
postcssrc({ map: { inline: true } });
|
||||
postcssrc({ env: 'development' }, 'path');
|
||||
postcssrc({ from: 'from', to: 'to' }, 'path', { cache: true }).then(({ options, plugins }) => {
|
||||
postcss(plugins).process('css', options);
|
||||
});
|
||||
|
||||
postcssrc.sync({ parser: 'my-parser' }, 'path', { cache: true });
|
||||
23
types/postcss-load-config/tsconfig.json
Normal file
23
types/postcss-load-config/tsconfig.json
Normal 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",
|
||||
"postcss-load-config-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/postcss-load-config/tslint.json
Normal file
1
types/postcss-load-config/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user