* 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
82 lines
1.3 KiB
TypeScript
82 lines
1.3 KiB
TypeScript
/// <reference path='fourslash.ts' />
|
|
// @strict: true
|
|
/////**
|
|
//// * @return {number}
|
|
//// */
|
|
////function [|f|](x, y) {
|
|
//// return x + y;
|
|
////}
|
|
////
|
|
/////**
|
|
//// * @return {number}
|
|
//// */
|
|
////function g(x, y): number {
|
|
//// return x + y;
|
|
////}
|
|
/////**
|
|
//// * @param {number} x
|
|
//// */
|
|
////function h(x: number, y): number {
|
|
//// return x + y;
|
|
////}
|
|
////
|
|
/////**
|
|
//// * @param {number} x
|
|
//// * @param {string} y
|
|
//// */
|
|
////function i(x: number, y: string) {
|
|
//// return x + y;
|
|
////}
|
|
/////**
|
|
//// * @param {number} x
|
|
//// * @return {boolean}
|
|
//// */
|
|
////function j(x: number, y): boolean {
|
|
//// return x < y;
|
|
////}
|
|
|
|
// Only first location triggers a suggestion
|
|
verify.getSuggestionDiagnostics([{
|
|
message: "JSDoc types may be moved to TypeScript types.",
|
|
code: 80004,
|
|
}]);
|
|
|
|
verify.codeFix({
|
|
description: "Annotate with type from JSDoc",
|
|
errorCode: 80004,
|
|
newFileContent:
|
|
`/**
|
|
* @return {number}
|
|
*/
|
|
function f(x, y): number {
|
|
return x + y;
|
|
}
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
function g(x, y): number {
|
|
return x + y;
|
|
}
|
|
/**
|
|
* @param {number} x
|
|
*/
|
|
function h(x: number, y): number {
|
|
return x + y;
|
|
}
|
|
|
|
/**
|
|
* @param {number} x
|
|
* @param {string} y
|
|
*/
|
|
function i(x: number, y: string) {
|
|
return x + y;
|
|
}
|
|
/**
|
|
* @param {number} x
|
|
* @return {boolean}
|
|
*/
|
|
function j(x: number, y): boolean {
|
|
return x < y;
|
|
}`,
|
|
});
|