From 07d7c9825d1c111f1083aaadf9fd4891eb7b1f7a Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 15 Oct 2023 12:16:18 -0400 Subject: [PATCH] fix(index): export default function and add `Comment` to index.d.ts --- index.d.ts | 57 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/index.d.ts b/index.d.ts index e666029..57c2d52 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,37 +2,44 @@ * Parses inline style to object. * * @example - * import StyleToObject from 'style-to-object'; - * StyleToObject('line-height: 42;'); + * + * ```ts + * import parse from 'style-to-object'; + * parse('line-height: 42;'); // { 'line-height': '42' } + * ``` */ -declare function StyleToObject( +export default function StyleToObject( style: string, - iterator?: StyleToObject.Iterator + iterator?: Iterator ): { [name: string]: string } | null; -export = StyleToObject; - -declare namespace StyleToObject { - interface DeclarationPos { +interface Position { + start: { + line: number; + column: number; + }; + end: { line: number; column: number; - } + }; + source?: string; +} - // declaration is an object from module `inline-style-parser` - interface Declaration { - type: string; - property: string; - value: string; - position: { - start: DeclarationPos; - end: DeclarationPos; - source: any; - }; - } +export interface Declaration { + type: 'declaration'; + property: string; + value: string; + position: Position; +} - type Iterator = ( - property: string, - value: string, - declaration: Declaration - ) => void; +export interface Comment { + type: 'comment'; + comment: string; + position: Position; } + +type Iterator = ( + property: string, + value: string, + declaration: Declaration | Comment +) => void;