Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update src/services/codefixes/helpers.ts
Simplify loop

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
  • Loading branch information
blickly and sandersn committed Aug 29, 2024
commit 4e216575afcc8d4c3ee1d9ca5c166dbf1dc99e4f
8 changes: 3 additions & 5 deletions src/services/codefixes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,12 @@ function endOfRequiredTypeParameters(checker: TypeChecker, type: GenericType): n
Debug.assert(type.typeArguments);
const fullTypeArguments = type.typeArguments;
const target = type.target;
next_cutoff: for (let cutoff = 0; cutoff < fullTypeArguments.length; cutoff++) {
for (let cutoff = 0; cutoff < fullTypeArguments.length; cutoff++) {
const typeArguments = fullTypeArguments.slice(0, cutoff);
const filledIn = checker.fillMissingTypeArguments(typeArguments, target.typeParameters, cutoff, /*isJavaScriptImplicitAny*/ false);
for (let i = 0; i < filledIn.length; i++) {
// If they don't match, then we haven't yet reached the right cutoff
if (filledIn[i] !== fullTypeArguments[i]) continue next_cutoff;
if (filledIn.every((fill, i) => fill === fullTypeArguments[i])) {
return cutoff;
}
return cutoff;
}
// If we make it all the way here, all the type arguments are required.
return fullTypeArguments.length;
Expand Down