mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Avoid calling indexOf when checking array element types (#18619)
* Avoid calling `indexOf` when checking array element types * Add 'indexOfNode' and use it in cases which may handle long lists. (#18635) * Fix bug where contextual type was not reused if undefined
This commit is contained in:
@@ -226,7 +226,7 @@ namespace ts.textChanges {
|
||||
Debug.fail("node is not a list element");
|
||||
return this;
|
||||
}
|
||||
const index = containingList.indexOf(node);
|
||||
const index = indexOfNode(containingList, node);
|
||||
if (index < 0) {
|
||||
return this;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ namespace ts.textChanges {
|
||||
Debug.fail("node is not a list element");
|
||||
return this;
|
||||
}
|
||||
const index = containingList.indexOf(after);
|
||||
const index = indexOfNode(containingList, after);
|
||||
if (index < 0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const children = list.getChildren();
|
||||
const listItemIndex = indexOf(children, node);
|
||||
const listItemIndex = indexOfNode(children, node);
|
||||
|
||||
return {
|
||||
listItemIndex,
|
||||
|
||||
Reference in New Issue
Block a user