Skip to content

Commit 3d672d9

Browse files
author
Andy
authored
Ensure fixSpelling and importFixes still trigger on "Did you mean the instance/static member ..." (#25847)
1 parent 00a6417 commit 3d672d9

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

src/services/codefixes/fixSpelling.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace ts.codefix {
44
const errorCodes = [
55
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
66
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
7+
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
8+
Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code,
79
Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2.code,
810
];
911
registerCodeFix({

src/services/codefixes/importFixes.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace ts.codefix {
44
const errorCodes: ReadonlyArray<number> = [
55
Diagnostics.Cannot_find_name_0.code,
66
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
7+
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
8+
Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code,
79
Diagnostics.Cannot_find_namespace_0.code,
810
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
911
Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,

tests/cases/fourslash/codeFixForgottenThisPropertyAccess01.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
/// <reference path='fourslash.ts' />
22

3+
// @Filename: /a.ts
4+
////export const foo = 0;
5+
6+
// @Filename: /b.ts
7+
////const fooo = 0;
38
////class C {
49
//// foo: number;
510
//// constructor() {[|
611
//// foo = 10;
712
//// |]}
813
////}
914

15+
goTo.file("/b.ts");
16+
verify.codeFixAvailable([
17+
{ description: `Import 'foo' from module "./a"` },
18+
{ description: "Change spelling to 'fooo'" },
19+
{ description: "Add 'this.' to unresolved variable" },
20+
]);
1021
verify.codeFix({
22+
index: 2,
1123
description: "Add 'this.' to unresolved variable",
1224
newRangeContent: `
1325
this.foo = 10;

tests/cases/fourslash/fourslash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ declare namespace FourSlashInterface {
609609
export interface VerifyCodeFixAvailableOptions {
610610
readonly description: string;
611611
readonly actions?: ReadonlyArray<{ readonly type: string, readonly data: {} }>;
612-
readonly commands?: ReadonlyArray<{}?;
612+
readonly commands?: ReadonlyArray<{}>;
613613
}
614614

615615
interface VerifyNavigateToOptions {

0 commit comments

Comments
 (0)