From 8fec609572a1c8219c1424934a326a9dddcf73ae Mon Sep 17 00:00:00 2001 From: hyperz111 Date: Fri, 2 Jan 2026 19:31:05 +0700 Subject: [PATCH 1/5] add index.d.ts --- index.d.ts | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..736e49e --- /dev/null +++ b/index.d.ts @@ -0,0 +1,59 @@ +// From DefinitelyTyped by Adam Thompson-Sharpe (https://github.com/MysteryBlokHed) with some modifications. +import { AcceptedPlugin, Root } from 'postcss' + +declare namespace postcssJs { + /** CSS-in-JS object */ + type CssInJs = Record + + /** + * 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 + */ + function sync( + plugins?: readonly AcceptedPlugin[] + ): (input: CssInJs) => CssInJs + 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 + */ + function async( + plugins?: readonly AcceptedPlugin[] + ): (input: CssInJs) => Promise + function async( + ...plugins: AcceptedPlugin[] + ): (input: CssInJs) => Promise + + /** + * Parse a CSS-in-JS object into a PostCSS `Root` + * @param obj The CSS-in-JS to parse + * @returns A PostCSS `Root` + */ + function parse(obj: CssInJs): Root + + interface ObjectifyOptions { + stringifyImportant?: boolean | undefined + } + + /** + * Convert a PostCSS `Root` into a CSS-in-JS object + * @param root The root to convert + * @returns CSS-in-JS object + */ + function objectifiy(root: Root, options?: ObjectifyOptions): CssInJs + + export { + CssInJs, + ObjectifyOptions, + sync, + async, + objectifiy, + parse, + postcssJs as default + } +} + +export = postcssJs From 5dc2d9d31e8046a10c716fd7b83fcd11741a2377 Mon Sep 17 00:00:00 2001 From: hyperz111 Date: Fri, 2 Jan 2026 19:31:55 +0700 Subject: [PATCH 2/5] add types for other files --- async.d.ts | 5 +++++ objectifier.d.ts | 5 +++++ parser.d.ts | 5 +++++ process-result.d.ts | 7 +++++++ sync.d.ts | 5 +++++ 5 files changed, 27 insertions(+) create mode 100644 async.d.ts create mode 100644 objectifier.d.ts create mode 100644 parser.d.ts create mode 100644 process-result.d.ts create mode 100644 sync.d.ts diff --git a/async.d.ts b/async.d.ts new file mode 100644 index 0000000..0a1bafd --- /dev/null +++ b/async.d.ts @@ -0,0 +1,5 @@ +import { async as _async } from './index.js' + +declare const async: typeof _async + +export = async diff --git a/objectifier.d.ts b/objectifier.d.ts new file mode 100644 index 0000000..1dce5dd --- /dev/null +++ b/objectifier.d.ts @@ -0,0 +1,5 @@ +import { objectifiy } from './index.js' + +declare const objectifier: typeof objectifiy + +export = objectifier diff --git a/parser.d.ts b/parser.d.ts new file mode 100644 index 0000000..56d34e8 --- /dev/null +++ b/parser.d.ts @@ -0,0 +1,5 @@ +import { parse } from './index.js' + +declare const parser: typeof parse + +export = parser diff --git a/process-result.d.ts b/process-result.d.ts new file mode 100644 index 0000000..5f1167a --- /dev/null +++ b/process-result.d.ts @@ -0,0 +1,7 @@ +import { CssInJs } from './index.js' +import { LazyResult } from 'postcss' +import NoWorkResult from 'postcss/lib/no-work-result' + +declare function processResult(result: LazyResult | NoWorkResult): CssInJs + +export = processResult diff --git a/sync.d.ts b/sync.d.ts new file mode 100644 index 0000000..bbed26c --- /dev/null +++ b/sync.d.ts @@ -0,0 +1,5 @@ +import { sync as _sync } from './index.js' + +declare const sync: typeof _sync + +export = sync From 5502aaaddd91633073980687c29f01b776523066 Mon Sep 17 00:00:00 2001 From: hyperz111 Date: Fri, 2 Jan 2026 19:32:13 +0700 Subject: [PATCH 3/5] add index.d.mts for ESM --- index.d.mts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 index.d.mts diff --git a/index.d.mts b/index.d.mts new file mode 100644 index 0000000..32d4129 --- /dev/null +++ b/index.d.mts @@ -0,0 +1,9 @@ +export { + CssInJs, + ObjectifyOptions, + sync, + async, + objectifiy, + parse, + default +} from './index.js' From 88b67f04655c9781f0262e20e6c4495ff29e54be Mon Sep 17 00:00:00 2001 From: hyperz111 Date: Fri, 2 Jan 2026 19:58:36 +0700 Subject: [PATCH 4/5] add ObjectifyOptions to objectifier.d.ts --- objectifier.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/objectifier.d.ts b/objectifier.d.ts index 1dce5dd..636626a 100644 --- a/objectifier.d.ts +++ b/objectifier.d.ts @@ -1,5 +1,7 @@ -import { objectifiy } from './index.js' +import { ObjectifyOptions, objectifiy } from './index.js' -declare const objectifier: typeof objectifiy +declare namespace objectifier { + export { ObjectifyOptions, objectifiy as default } +} export = objectifier From aee18e2664a8432e5da4cba14a1f6b465d1bbb72 Mon Sep 17 00:00:00 2001 From: Hyper-Z11 Date: Wed, 14 Jan 2026 17:59:51 +0700 Subject: [PATCH 5/5] fix: objectif(i)y --- index.d.mts | 2 +- index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.mts b/index.d.mts index 32d4129..2806382 100644 --- a/index.d.mts +++ b/index.d.mts @@ -3,7 +3,7 @@ export { ObjectifyOptions, sync, async, - objectifiy, + objectify, parse, default } from './index.js' diff --git a/index.d.ts b/index.d.ts index 736e49e..3917874 100644 --- a/index.d.ts +++ b/index.d.ts @@ -43,14 +43,14 @@ declare namespace postcssJs { * @param root The root to convert * @returns CSS-in-JS object */ - function objectifiy(root: Root, options?: ObjectifyOptions): CssInJs + function objectify(root: Root, options?: ObjectifyOptions): CssInJs export { CssInJs, ObjectifyOptions, sync, async, - objectifiy, + objectify, parse, postcssJs as default }