-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add type definition file * Mention type definition original project * Fix npm registry Co-authored-by: dengbin03 <dengbin03@kuaishou.com>
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
package-lock=false | ||
registry=https://registry.npmjs.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// based on @types/postcss-load-config@2.0.1 | ||
// Type definitions for postcss-load-config 2.1 | ||
import Processor from 'postcss/lib/processor' | ||
import { Plugin, ProcessOptions, Transformer } from "postcss"; | ||
import { Options as CosmiconfigOptions } from '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 | Transformer | Processor; | ||
|
||
interface Result { | ||
file: string; | ||
options: ProcessOptions; | ||
plugins: ResultPlugin[]; | ||
} | ||
|
||
declare function postcssrc(ctx?: ConfigContext, path?: string, options?: CosmiconfigOptions): Promise<Result>; | ||
|
||
declare namespace postcssrc { | ||
function sync(ctx?: ConfigContext, path?: string, options?: CosmiconfigOptions): Result; | ||
} | ||
|
||
export = postcssrc; |