File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
Expand file tree Collapse file tree 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
151151 }
152152
153153 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.
154165@@ -21527,11 +21549,11 @@
155166 };
156167
Original file line number Diff line number Diff line change @@ -19118,7 +19118,7 @@ declare var NodeList: {
1911819118};
1911919119
1912019120interface NodeListOf<TNode extends Node> extends NodeList {
19121- item(index: number): TNode;
19121+ item(index: number): TNode | null ;
1912219122 /**
1912319123 * Performs the specified action for each node in an list.
1912419124 * @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 {
1913019130 ): void;
1913119131 [index: number]: TNode;
1913219132}
19133+ // item(index: number): TNode;
1913319134
1913419135interface NonDocumentTypeChildNode {
1913519136 /**
Original file line number Diff line number Diff line change @@ -218,3 +218,7 @@ declare function structuredClone<
218218 value : T ,
219219 options ?: StructuredSerializeOptions ,
220220) : 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) => {
137137 }
138138 }
139139}
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