mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
fix(59558): Implement Interface Quick Fix generates duplicate declarations (#59563)
This commit is contained in:
@@ -301,6 +301,9 @@ export function addNewNodeForMemberSymbol(
|
||||
}
|
||||
|
||||
for (const signature of signatures) {
|
||||
if (signature.declaration && (signature.declaration.flags & NodeFlags.Ambient)) {
|
||||
continue;
|
||||
}
|
||||
// Ensure nodes are fresh so they can have different positions when going through formatting.
|
||||
outputMethod(quotePreference, signature, modifiers, createName(declarationName));
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}`
|
||||
});
|
||||
@@ -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.");
|
||||
}
|
||||
}`
|
||||
});
|
||||
@@ -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.");
|
||||
}
|
||||
}`
|
||||
});
|
||||
Reference in New Issue
Block a user