From 0b773f144b0e4f718581db988d6538cf20a192f3 Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:46:34 +0200 Subject: [PATCH] fix: improve typings of constructor helpers (#292) --- postcss-selector-parser.d.ts | 6 +++--- src/__tests__/constructors.mjs | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/__tests__/constructors.mjs diff --git a/postcss-selector-parser.d.ts b/postcss-selector-parser.d.ts index 9163ab1..af609e6 100644 --- a/postcss-selector-parser.d.ts +++ b/postcss-selector-parser.d.ts @@ -532,13 +532,13 @@ declare namespace parser { interface Identifier extends Base { type: "id"; } - function id(opts: any): any; + function id(opts: any): Identifier; function isIdentifier(node: any): node is Identifier; interface Nesting extends Base { type: "nesting"; } - function nesting(opts: any): any; + function nesting(opts?: any): Nesting; function isNesting(node: any): node is Nesting; interface String extends Base { @@ -550,6 +550,6 @@ declare namespace parser { interface Universal extends Base { type: "universal"; } - function universal(opts?: NamespaceOptions): any; + function universal(opts?: NamespaceOptions): Universal; function isUniversal(node: any): node is Universal; } diff --git a/src/__tests__/constructors.mjs b/src/__tests__/constructors.mjs new file mode 100644 index 0000000..6008638 --- /dev/null +++ b/src/__tests__/constructors.mjs @@ -0,0 +1,7 @@ +import test from 'ava'; +import parser from '../index.js'; + +test('constructors#nesting', (t) => { + t.deepEqual(parser.nesting().toString(), '&'); + t.deepEqual(parser.nesting({}).toString(), '&'); +});