@@ -18,17 +18,17 @@ import * as postcss from "postcss";
18
18
19
19
export interface NodeBase {
20
20
// Inherited from postcss.ContainerBase, but with our Node type.
21
- next ( ) : Node | void ;
22
- prev ( ) : Node | void ;
23
- before ( newNode : Node | object | string | Node [ ] ) : this;
24
- after ( newNode : Node | object | string | Node [ ] ) : this;
21
+ next ( ) : ChildNode | void ;
22
+ prev ( ) : ChildNode | void ;
23
+ before ( newNode : ChildNode | object | string | ChildNode [ ] ) : this;
24
+ after ( newNode : ChildNode | object | string | ChildNode [ ] ) : this;
25
25
root ( ) : Root ;
26
- replaceWith ( ...nodes : Array < Node | object > ) : this;
26
+ replaceWith ( ...nodes : Array < ChildNode | object > ) : this;
27
27
28
28
// Inherited from postcss.ContainerBase with no changes.
29
29
source ?: postcss . NodeSource ;
30
30
raws : postcss . NodeRaws ;
31
- toString ( stringifier ?: postcss . Stringifier | postcss . Syntax ) : string ;
31
+ toString ( stringifier ?: Stringifier | Syntax ) : string ;
32
32
error (
33
33
message : string ,
34
34
options ?: postcss . NodeErrorOptions
@@ -66,33 +66,39 @@ export interface ContainerBase extends NodeBase {
66
66
walkWords ( callback : ( word : Word , index : number ) => any ) : boolean | void ;
67
67
walkType (
68
68
type : string ,
69
- callback : ( node : Node , index : number ) => any
69
+ callback : ( node : ChildNode , index : number ) => any
70
70
) : boolean | void ;
71
71
72
72
// Inherited from postcss.ContainerBase, but with our Node type.
73
- nodes : Node [ ] ;
74
- first ?: Node ;
75
- last ?: Node ;
76
- index ( child : Node | number ) : number ;
73
+ nodes : ChildNode [ ] ;
74
+ first ?: ChildNode ;
75
+ last ?: ChildNode ;
76
+ index ( child : ChildNode | number ) : number ;
77
77
every (
78
- callback : ( node : Node , index : number , nodes : Node [ ] ) => any ,
78
+ callback : ( node : ChildNode , index : number , nodes : ChildNode [ ] ) => any ,
79
79
thisArg ?: any
80
80
) : boolean ;
81
81
some (
82
- callback : ( node : Node , index : number , nodes : Node [ ] ) => boolean ,
82
+ callback : ( node : ChildNode , index : number , nodes : ChildNode [ ] ) => boolean ,
83
83
thisArg ?: any
84
84
) : boolean ;
85
- each ( callback : ( node : Node , index : number ) => any ) : boolean | void ;
86
- walk ( callback : ( node : Node , index : number ) => any ) : boolean | void ;
85
+ each ( callback : ( node : ChildNode , index : number ) => any ) : boolean | void ;
86
+ walk ( callback : ( node : ChildNode , index : number ) => any ) : boolean | void ;
87
87
walkAtWords ( callback : ( atWord : AtWord , index : number ) => any ) : boolean | void ;
88
88
walkComments (
89
89
callback : ( comment : Comment , index : number ) => any
90
90
) : boolean | void ;
91
- prepend ( ...nodes : Array < Node | object | string > ) : this;
92
- append ( ...nodes : Array < Node | object | string > ) : this;
93
- insertBefore ( oldNode : Node | number , newNode : Node | object | string ) : this;
94
- insertAfter ( oldNode : Node | number , newNode : Node | object | string ) : this;
95
- removeChild ( child : Node | number ) : this;
91
+ prepend ( ...nodes : Array < ChildNode | object | string > ) : this;
92
+ append ( ...nodes : Array < ChildNode | object | string > ) : this;
93
+ insertBefore (
94
+ oldNode : ChildNode | number ,
95
+ newNode : ChildNode | object | string
96
+ ) : this;
97
+ insertAfter (
98
+ oldNode : ChildNode | number ,
99
+ newNode : ChildNode | object | string
100
+ ) : this;
101
+ removeChild ( child : ChildNode | number ) : this;
96
102
97
103
// Inherited from postcss.ContainerBase with no changes.
98
104
clone ( overrides ?: object ) : this;
@@ -109,7 +115,9 @@ export interface Root extends ContainerBase {
109
115
} ) : postcss . Result ;
110
116
}
111
117
112
- export type Node =
118
+ export type Node = Root | ChildNode ;
119
+
120
+ export type ChildNode =
113
121
| AtWord
114
122
| Comment
115
123
| Func
@@ -121,7 +129,7 @@ export type Node =
121
129
| UnicodeRange
122
130
| Word ;
123
131
124
- export type Container = Func | Interpolation ;
132
+ export type Container = Root | Func | Interpolation ;
125
133
126
134
export interface AtWord extends NodeBase {
127
135
type : "atrule" ;
@@ -141,6 +149,7 @@ export interface Func extends ContainerBase {
141
149
type : "func" ;
142
150
parent : Container ;
143
151
isColor : boolean ;
152
+ isVar : boolean ;
144
153
name : string ;
145
154
params : string ;
146
155
}
@@ -210,6 +219,18 @@ export interface VariablesOptions {
210
219
prefixes : string [ ] ;
211
220
}
212
221
213
- export const stringify : postcss . Stringifier ;
222
+ interface Syntax {
223
+ stringify ?: Stringifier ;
224
+ }
225
+
226
+ interface Builder {
227
+ ( part : string , node ?: Node , type ?: "start" | "end" ) : void ;
228
+ }
229
+
230
+ export interface Stringifier {
231
+ ( node : Node , builder : Builder ) : void ;
232
+ }
233
+
234
+ export const stringify : Stringifier ;
214
235
215
236
export function nodeToString ( node : Node ) : string ;
0 commit comments