Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2150,10 +2150,18 @@ namespace FourSlash {
* @param fileName Path to file where error should be retrieved from.
*/
private getCodeFixActions(fileName: string, errorCode?: number): ts.CodeAction[] {
const diagnostics: ts.Diagnostic[] = this.getDiagnostics(fileName);
const diagnosticsForCodeFix = this.getDiagnostics(fileName).map(diagnostic => {
return {
start: diagnostic.start,
length: diagnostic.length,
code: diagnostic.code
}
});
const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties);

let actions: ts.CodeAction[] = undefined;
for (const diagnostic of diagnostics) {

for (const diagnostic of dedupedDiagnositcs) {

if (errorCode && errorCode !== diagnostic.code) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ namespace ts {

let allFixes: CodeAction[] = [];

forEach(errorCodes, error => {
forEach(deduplicate(errorCodes), error => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forEach(deduplicate(errorCodes), error => { 

cancellationToken.throwIfCancellationRequested();

const context = {
Expand Down
6 changes: 5 additions & 1 deletion tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

//// abstract class A {
//// abstract x: number;
//// abstract foo(): number;
//// }
////
//// class C extends A {[|
//// |]}

verify.rangeAfterCodeFix(`
x: number;
x: number;
foo(): number {
throw new Error('Method not implemented.');
}
`);