-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(59558): Implement Interface Quick Fix generates duplicate declara…
…tions (#59563)
- Loading branch information
1 parent
8ec3804
commit f850298
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/cases/fourslash/codeFixClassImplementInterfaceWithAmbientSignatures1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @lib: esnext | ||
// @target: esnext | ||
|
||
// @Filename: /node_modules/@types/node/globals.d.ts | ||
////export {}; | ||
////declare global { | ||
//// interface SymbolConstructor { | ||
//// readonly dispose: unique symbol; | ||
//// } | ||
//// interface Disposable { | ||
//// [Symbol.dispose](): void; | ||
//// } | ||
////} | ||
|
||
// @Filename: /node_modules/@types/node/index.d.ts | ||
/////// <reference path="globals.d.ts" /> | ||
|
||
// @Filename: a.ts | ||
////class Foo implements Disposable {} | ||
|
||
goTo.file("a.ts"); | ||
verify.codeFix({ | ||
description: "Implement interface 'Disposable'", | ||
newFileContent: | ||
`class Foo implements Disposable { | ||
[Symbol.dispose](): void { | ||
throw new Error("Method not implemented."); | ||
} | ||
}` | ||
}); |
19 changes: 19 additions & 0 deletions
19
tests/cases/fourslash/codeFixClassImplementInterfaceWithAmbientSignatures2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////declare class A { | ||
//// method(): void; | ||
////} | ||
////class B implements A {} | ||
|
||
verify.codeFix({ | ||
description: "Implement interface 'A'", | ||
newFileContent: | ||
`declare class A { | ||
method(): void; | ||
} | ||
class B implements A { | ||
method(): void { | ||
throw new Error("Method not implemented."); | ||
} | ||
}` | ||
}); |
19 changes: 19 additions & 0 deletions
19
tests/cases/fourslash/codeFixClassImplementInterfaceWithAmbientSignatures3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////declare abstract class A { | ||
//// abstract method(): void; | ||
////} | ||
////class B implements A {} | ||
|
||
verify.codeFix({ | ||
description: "Implement interface 'A'", | ||
newFileContent: | ||
`declare abstract class A { | ||
abstract method(): void; | ||
} | ||
class B implements A { | ||
method(): void { | ||
throw new Error("Method not implemented."); | ||
} | ||
}` | ||
}); |