From 410513462673bad5696dad89b7103f31681ca1c6 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 4 Dec 2024 13:22:25 -0800 Subject: [PATCH] Include type-meaning 'extends' clause in auto-import fix list (#59853) --- src/services/codefixes/importFixes.ts | 1 + tests/cases/fourslash/importNameCodeFix_all.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index b23b7c127e872..a1537c8bde5b7 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -183,6 +183,7 @@ const errorCodes: readonly number[] = [ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode.code, Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig.code, Diagnostics.Cannot_find_namespace_0_Did_you_mean_1.code, + Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code, Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found.code, ]; diff --git a/tests/cases/fourslash/importNameCodeFix_all.ts b/tests/cases/fourslash/importNameCodeFix_all.ts index f76a5d1aa6950..de0527f5c9c0f 100644 --- a/tests/cases/fourslash/importNameCodeFix_all.ts +++ b/tests/cases/fourslash/importNameCodeFix_all.ts @@ -21,6 +21,12 @@ ////declare function e(): void; ////export = e; +// @Filename: /disposable.d.ts +////export declare class Disposable { } + +// @Filename: /disposable_global.d.ts +////interface Disposable { } + // @Filename: /user.ts ////import * as b from "./b"; ////import { } from "./c"; @@ -31,6 +37,7 @@ ////cd; cd; c0; c0; ////dd; dd; d0; d0; d1; d1; ////e; e; +////class X extends Disposable { } goTo.file("/user.ts"); verify.codeFixAll({ @@ -41,11 +48,13 @@ verify.codeFixAll({ import bd, * as b from "./b"; import cd, { c0 } from "./c"; import dd, { d0, d1 } from "./d"; +import { Disposable } from "./disposable"; import e = require("./e"); ad; ad; a0; a0; bd; bd; b.b0; b.b0; cd; cd; c0; c0; dd; dd; d0; d0; d1; d1; -e; e;`, +e; e; +class X extends Disposable { }`, });