Skip to content

Commit 07d7c98

Browse files
fix(index): export default function and add Comment to index.d.ts
1 parent 6c278b8 commit 07d7c98

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

index.d.ts

+32-25
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,44 @@
22
* Parses inline style to object.
33
*
44
* @example
5-
* import StyleToObject from 'style-to-object';
6-
* StyleToObject('line-height: 42;');
5+
*
6+
* ```ts
7+
* import parse from 'style-to-object';
8+
* parse('line-height: 42;'); // { 'line-height': '42' }
9+
* ```
710
*/
8-
declare function StyleToObject(
11+
export default function StyleToObject(
912
style: string,
10-
iterator?: StyleToObject.Iterator
13+
iterator?: Iterator
1114
): { [name: string]: string } | null;
1215

13-
export = StyleToObject;
14-
15-
declare namespace StyleToObject {
16-
interface DeclarationPos {
16+
interface Position {
17+
start: {
18+
line: number;
19+
column: number;
20+
};
21+
end: {
1722
line: number;
1823
column: number;
19-
}
24+
};
25+
source?: string;
26+
}
2027

21-
// declaration is an object from module `inline-style-parser`
22-
interface Declaration {
23-
type: string;
24-
property: string;
25-
value: string;
26-
position: {
27-
start: DeclarationPos;
28-
end: DeclarationPos;
29-
source: any;
30-
};
31-
}
28+
export interface Declaration {
29+
type: 'declaration';
30+
property: string;
31+
value: string;
32+
position: Position;
33+
}
3234

33-
type Iterator = (
34-
property: string,
35-
value: string,
36-
declaration: Declaration
37-
) => void;
35+
export interface Comment {
36+
type: 'comment';
37+
comment: string;
38+
position: Position;
3839
}
40+
41+
type Iterator = (
42+
property: string,
43+
value: string,
44+
declaration: Declaration | Comment
45+
) => void;

0 commit comments

Comments
 (0)