You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rehearsal currently just looping through available codefixes and trying to apply the next only if current didn't work.
This is more hypothetical case then real, in reality the first fix should fix the issue.
// Try the next fix if we already tried the first one
fix=fixes.shift();
}
The sample of code has 2 fixes:
infer type from usage
add type based on inheritance
export class A {
generate(dimensions: number[]): void {
console.log(dimensions)
}
}
export class B extends A {
generate(dimensions): void {
for (let y = 0; y < dimensions[1]; y++) {
for (let x = 0; x < dimensions[0]; x++) {
console.log(x, y)
}
}
}
}
Instead of just blindly loop over, we can compare results and return only one fix with better types.
This will also allow to optimize drain mode to reduce number of attempts to process the same diagnostic with adopting this kind of exit criteria instead of checking if there are any additinal fixes left inside the cycle.
To achieve this we need to create an extendable list of comparison functions for codefixes (those can be returned together) and just call appropriate function to compare when we have more then 1 fix.
The text was updated successfully, but these errors were encountered:
Though:
Rehearsal currently just looping through available codefixes and trying to apply the next only if current didn't work.
This is more hypothetical case then real, in reality the first fix should fix the issue.
rehearsal-js/packages/plugins/src/plugins/diagnostic-fix.plugin.ts
Lines 231 to 237 in cbb9f38
The sample of code has 2 fixes:
Instead of just blindly loop over, we can compare results and return only one fix with better types.
This will also allow to optimize
drain
mode to reduce number of attempts to process the same diagnostic with adopting this kind of exit criteria instead of checking if there are any additinal fixes left inside the cycle.To achieve this we need to create an extendable list of comparison functions for codefixes (those can be returned together) and just call appropriate function to compare when we have more then 1 fix.
The text was updated successfully, but these errors were encountered: