8000 Improve performance: do not add unused suggestion diagnostics unless … · microsoft/TypeScript@90313d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 90313d2

Browse files
author
Andy Hanson
committed
Improve performance: do not add unused suggestion diagnostics unless asking for a suggestion
1 parent 3a04ac0 commit 90313d2

14 files changed

+158
-117
lines changed

src/compiler/checker.ts

Lines changed: 127 additions & 81 deletions
Large diffs are not rendered by default.

tests/cases/fourslash/annotateWithTypeFromJSDoc15.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ verify.codeFix({
3030
* @param {promise<String>} zeta
3131
*/
3232
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta: Array<any>, epsilon: Array<number>, zeta: Promise<string>) {
33-
x;
34-
y;
35-
z;
36-
alpha;
37-
beta;
38-
gamma;
39-
delta;
40-
epsilon;
41-
zeta;
33+
x; y; z; alpha; beta; gamma; delta; epsilon; zeta;
4234
}`,
4335
});

tests/cases/fourslash/annotateWithTypeFromJSDoc22.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ verify.codeFix({
1414
/** @param {Object<string, boolean>} sb
1515
* @param {Object<number, string>} ns */
1616
function f(sb: { [s: string]: boolean; }, ns: { [n: number]: string; }) {
17-
sb;
18-
ns;
17+
sb; ns;
1918
}`,
2019
});

tests/cases/fourslash/annotateWithTypeFromJSDoc3.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ verify.codeFix({
2727
* @param {*} beta - I have no idea how this got here
2828
*/
2929
function f(x: number, y: { a: string; b: Date; }, z: string, alpha, beta: any) {
30-
x;
31-
y;
32-
z;
33-
alpha;
34-
beta;
30+
x; y; z; alpha; beta;
3531
}`,
3632
});

tests/cases/fourslash/annotateWithTypeFromJSDoc4.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ verify.codeFix({
2626
* @param {number!} delta
2727
*/
2828
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: { a: string; }, arg1: string, arg2: number) => boolean, gamma: number | null, delta: number) {
29-
x;
30-
y;
31-
z;
32-
alpha;
33-
beta;
34-
gamma;
35-
delta;
29+
x; y; z; alpha; beta; gamma; delta;
3630
}`,
3731
});

tests/cases/fourslash/annotateWithTypeFromJSDoc8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ verify.codeFix({
1515
* @param {number} x
1616
* @returns {number}
1717
*/
18-
var f = function(x: number): number {
18+
var f = function (x: number): number {
1919
return x
2020
}`,
2121
});

tests/cases/fourslash/refactorConvertToEs6Module_export_referenced.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
////exports.y;
1212
////
1313
////exports.z = 2;
14-
////function f(z) {
15-
//// exports.z;
14+
////exports.f = function(z) {
15+
//// exports.z; z;
1616
////}
1717

1818
verify.codeFix({
1919
description: "Convert to ES6 module",
20+
// TODO: GH#22492
2021
newFileContent:
2122
`export const x = 0;
2223
x;
@@ -28,7 +29,7 @@ _y;
2829
2930
const _z = 2;
3031
export { _z as z };
31-
function f(z) {
32-
_z;
32+
export function f(z) {
33+
_z z;
3334
}`,
3435
});

tests/cases/fourslash/refactorConvertToEs6Module_expressionToDeclaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// @allowJs: true
44

55
// @Filename: /a.js
6-
////exports.f = async function* f(p) {}
6+
////exports.f = async function* f(p) { p; }
77
////exports.C = class C extends D { m() {} }
88

99
verify.codeFix({
1010
description: "Convert to ES6 module",
1111
newFileContent:
12-
`export async function* f(p) { }
12+
`export async function* f(p) { p; }
1313
export class C extends D {
1414
m() { }
1515
}`,

tests/cases/fourslash/refactorConvertToEs6Module_import_arrayBindingPattern.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
// @Filename: /a.js
66
////const [x, y] = /*a*/require/*b*/("x");
7+
////x; y;
78

89
verify.codeFix({
910
description: "Convert to ES6 module",
1011
newFileContent: `import _x from "x";
11-
const [x, y] = _x;`,
12+
const [x, y] = _x;
13+
x; y;`,
1214
});

tests/cases/fourslash/refactorConvertToEs6Module_import_multipleUniqueIdentifiers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
////const x = require("x");
77
////const [a, b] = require("x");
88
////const {c, ...d} = require("x");
9+
////x; a; b; c; d;
910

1011
verify.codeFix({
1112
description: "Convert to ES6 module",
@@ -14,5 +15,6 @@ verify.codeFix({
1415
import _x from "x";
1516
const [a, b] = _x;
1617
import __x from "x";
17-
const { c, ...d } = __x;`,
18+
const { c, ...d } = __x;
19+
x; a; b; c; d;`,
1820
});

0 commit comments

Comments
 (0)
0