File tree 4 files changed +28
-1
lines changed
4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,17 @@ Index: dom.generated.d.ts
151
151
}
152
152
153
153
declare var MIDIOutputMap: {
154
+ @@ -19085,9 +19107,9 @@
155
+ new (): NodeList;
156
+ };
157
+
158
+ interface NodeListOf<TNode extends Node> extends NodeList {
159
+ - item(index: number): TNode;
160
+ + item(index: number): TNode | null;
161
+ /**
162
+ * Performs the specified action for each node in an list.
163
+ * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
164
+ * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
154
165
@@ -21527,11 +21549,11 @@
155
166
};
156
167
Original file line number Diff line number Diff line change @@ -19118,7 +19118,7 @@ declare var NodeList: {
19118
19118
};
19119
19119
19120
19120
interface NodeListOf<TNode extends Node> extends NodeList {
19121
- item(index: number): TNode;
19121
+ item(index: number): TNode | null ;
19122
19122
/**
19123
19123
* Performs the specified action for each node in an list.
19124
19124
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
@@ -19130,6 +19130,7 @@ interface NodeListOf<TNode extends Node> extends NodeList {
19130
19130
): void;
19131
19131
[index: number]: TNode;
19132
19132
}
19133
+ // item(index: number): TNode;
19133
19134
19134
19135
interface NonDocumentTypeChildNode {
19135
19136
/**
Original file line number Diff line number Diff line change @@ -218,3 +218,7 @@ declare function structuredClone<
218
218
value : T ,
219
219
options ?: StructuredSerializeOptions ,
220
220
) : BetterTypeScriptLibInternals . StructuredClone . StructuredCloneOutput < T > ;
221
+
222
+ interface NodeListOf < TNode extends Node > extends NodeList {
223
+ item ( index : number ) : TNode | null ;
224
+ }
Original file line number Diff line number Diff line change @@ -137,3 +137,14 @@ const test = async (url: string) => {
137
137
}
138
138
}
139
139
}
140
+
141
+ // NodeListOf
142
+ {
143
+ // https://github.com/uhyo/better-typescript-lib/issues/43
144
+ const list : NodeListOf < HTMLDivElement > = document . querySelectorAll ( "div" ) ;
145
+
146
+ const item = list . item ( 100 ) ;
147
+ expectType < HTMLDivElement | null > ( item ) ;
148
+ // @ts -expect-error
149
+ item . append ( "a" ) ;
150
+ }
You can’t perform that action at this time.
0 commit comments