Skip to content

Commit

Permalink
For @types installing quickfix, only activate for implicit-any module (
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy committed Oct 24, 2017
1 parent 43fc3ce commit 02cc07c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/services/codefixes/fixCannotFindModule.ts
Expand Up @@ -2,7 +2,6 @@
namespace ts.codefix {
registerCodeFix({
errorCodes: [
Diagnostics.Cannot_find_module_0.code,
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code,
],
getCodeActions: context => {
Expand Down
11 changes: 10 additions & 1 deletion tests/cases/fourslash/codeFixCannotFindModule.ts
@@ -1,11 +1,20 @@
/// <reference path='fourslash.ts' />

////import * as abs from "abs";
// @moduleResolution: node
// @noImplicitAny: true

// @Filename: /node_modules/abs/index.js
////not read

// @Filename: /a.ts
/////**/import * as abs from "abs";

test.setTypesRegistry({
"abs": undefined,
});

goTo.marker();

verify.codeFixAvailable([{
description: "Install '@types/abs'",
commands: [{
Expand Down
11 changes: 11 additions & 0 deletions tests/cases/fourslash/codeFixCannotFindModule_notIfMissing.ts
@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />

// @Filename: /a.ts
////import * as abs from "abs";

test.setTypesRegistry({
"abs": undefined,
});

// We only give the fix for an implicit-any module, not for a missing module.
verify.not.codeFixAvailable();

0 comments on commit 02cc07c

Please sign in to comment.