TypeScript/tests/cases/fourslash/codeFixCannotFindModule_suggestion_js.ts
Andy 24842b4002
When --noUnusedLocals/--noUnusedParameters is disabled, add suggestions instead of errors (#22361)
* When --noUnusedLocals/--noUnusedParameters is disabled, add suggestions instead of errors

* Improve performance: do not add unused suggestion diagnostics unless asking for a suggestion

* Add "unused" flag to diagnostics

* Code review

* reportsUnused -> reportsUnnecessary

* Fix test
2018-04-05 12:33:00 -07:00

34 lines
814 B
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @Filename: /node_modules/abs/index.js
////export default function abs() {}
// @Filename: /a.js
////import abs from [|"abs"|];
////abs;
test.setTypesRegistry({ "abs": undefined });
verify.noErrors();
goTo.file("/a.js");
verify.getSuggestionDiagnostics([{
message: "Could not find a declaration file for module 'abs'. '/node_modules/abs/index.js' implicitly has an 'any' type.",
code: 7016,
}]);
verify.codeFixAvailable([
{
description: "Install '@types/abs'",
commands: [{
type: "install package",
file: "/a.js",
packageName: "@types/abs",
}],
},
{ description: "Ignore this error message" },
{ description: "Disable checking for this file" },
]);