Skip to content

Commit df643d8

Browse files
authored
Merge pull request #13405 from zhengbli/13137
Support import fix for missing namespace
2 parents a2451a4 + e532744 commit df643d8

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/services/codefixes/importFixes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ namespace ts.codefix {
115115
registerCodeFix({
116116
errorCodes: [
117117
Diagnostics.Cannot_find_name_0.code,
118+
Diagnostics.Cannot_find_namespace_0.code,
118119
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
119120
],
120121
getCodeActions: (context: CodeFixContext) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// [|let t: XXX/*0*/.I;|]
4+
5+
// @Filename: ./module.ts
6+
//// export module XXX {
7+
//// export interface I {
8+
//// }
9+
//// }
10+
11+
verify.importFixAtPosition([
12+
`import { XXX } from "./module";
13+
14+
let t: XXX.I;`
15+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// [|let t: A/*0*/.B.I;|]
4+
5+
// @Filename: ./module.ts
6+
//// export namespace A {
7+
//// export namespace B {
8+
//// export interface I { }
9+
//// }
10+
//// }
11+
12+
verify.importFixAtPosition([
13+
`import { A } from "./module";
14+
15+
let t: A.B.I;`
16+
]);

0 commit comments

Comments
 (0)