From a628250d80be9f95363431c8506ee0782531f7d9 Mon Sep 17 00:00:00 2001 From: dengbin03 Date: Sun, 7 Feb 2021 12:07:07 +0800 Subject: [PATCH 1/3] Add type definition file --- package.json | 1 + types/index.d.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index 3196ad0..56de3c5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "3.0.0", "description": "Autoload Config for PostCSS", "main": "src/index.js", + "types": "types/index.d.ts", "files": [ "src" ], diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..aaf29d0 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,44 @@ +// 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>; + +// 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; + +declare namespace postcssrc { + function sync(ctx?: ConfigContext, path?: string, options?: CosmiconfigOptions): Result; +} + +export = postcssrc; From bb58884a711996cf0b27eda667a3597c07510862 Mon Sep 17 00:00:00 2001 From: dengbin03 Date: Sun, 7 Feb 2021 12:47:59 +0800 Subject: [PATCH 2/3] Mention type definition original project --- types/index.d.ts | 1 + yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index aaf29d0..b2241cd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,4 @@ +// 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"; diff --git a/yarn.lock b/yarn.lock index d88374d..48f2042 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1297,8 +1297,8 @@ cosmiconfig@^5.0.0, cosmiconfig@^5.0.7: cosmiconfig@^7.0.0: version "7.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" - integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA== + resolved "https://npm.corp.kuaishou.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" + integrity sha1-75tE13OVnK5j3ezRIt4jhTtg+NM= dependencies: "@types/parse-json" "^4.0.0" import-fresh "^3.2.1" From 1a74376192b92cb777e1774a7e6f296f0a5e7426 Mon Sep 17 00:00:00 2001 From: dengbin03 Date: Sun, 7 Feb 2021 13:12:37 +0800 Subject: [PATCH 3/3] Fix npm registry --- .npmrc | 1 + yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.npmrc b/.npmrc index 43c97e7..29426fa 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ package-lock=false +registry=https://registry.npmjs.org \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 48f2042..d88374d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1297,8 +1297,8 @@ cosmiconfig@^5.0.0, cosmiconfig@^5.0.7: cosmiconfig@^7.0.0: version "7.0.0" - resolved "https://npm.corp.kuaishou.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" - integrity sha1-75tE13OVnK5j3ezRIt4jhTtg+NM= + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" + integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA== dependencies: "@types/parse-json" "^4.0.0" import-fresh "^3.2.1"