feat(44799): allow auto import codefix for shorthand property assignment (#44827)

This commit is contained in:
Oleksandr T
2021-07-01 00:09:42 +03:00
committed by GitHub
parent 813ddf7909
commit e402c1d464
3 changed files with 30 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ namespace ts.codefix {
Diagnostics.Cannot_find_namespace_0.code,
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
];
registerCodeFix({

View File

@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const a = 1;
// @Filename: /b.ts
////const b = { /**/a };
goTo.file("/b.ts");
verify.importFixAtPosition([
`import { a } from "./a";
const b = { a };`
]);

View File

@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////const a = 1;
////export default a;
// @Filename: /b.ts
////const b = { /**/a };
goTo.file("/b.ts");
verify.importFixAtPosition([
`import a from "./a";
const b = { a };`
]);