Skip to content

Commit 91b0e50

Browse files
DanielRosenwassermprobst
authored andcommitted
Remove unnecessary annotations/casts/aliases (microsoft#46727)
* Remove unnecessary annotation. * Remove more unnecessary stuff. * Remove unnecessary assertion.
1 parent 7f82811 commit 91b0e50

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43062,8 +43062,7 @@ namespace ts {
4306243062

4306343063
// Modifiers are never allowed on properties except for 'async' on a method declaration
4306443064
if (prop.modifiers) {
43065-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
43066-
for (const mod of prop.modifiers!) { // TODO: GH#19955
43065+
for (const mod of prop.modifiers) {
4306743066
if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) {
4306843067
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
4306943068
}

src/services/codefixes/convertToEsModule.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ namespace ts.codefix {
408408
const importSpecifiers = mapAllOrFail(name.elements, e =>
409409
e.dotDotDotToken || e.initializer || e.propertyName && !isIdentifier(e.propertyName) || !isIdentifier(e.name)
410410
? undefined
411-
// (TODO: GH#18217)
412-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
413-
: makeImportSpecifier(e.propertyName && (e.propertyName as Identifier).text, e.name.text));
411+
: makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text));
414412
if (importSpecifiers) {
415413
return convertedImports([makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
416414
}

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ namespace ts.FindAllReferences {
13231323
if (!symbol) return undefined;
13241324
for (const token of getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer)) {
13251325
if (!isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) continue;
1326-
const referenceSymbol: Symbol = checker.getSymbolAtLocation(token)!; // See GH#19955 for why the type annotation is necessary
1326+
const referenceSymbol = checker.getSymbolAtLocation(token)!;
13271327
if (referenceSymbol === symbol
13281328
|| checker.getShorthandAssignmentValueSymbol(token.parent) === symbol
13291329
|| isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) {

src/services/refactors/extractSymbol.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ namespace ts.refactor.extractSymbol {
314314
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
315315
}
316316
const statements: Statement[] = [];
317-
const start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248
318-
for (const statement of (start2.parent as BlockLike).statements) {
317+
for (const statement of start.parent.statements) {
319318
if (statement === start || statements.length) {
320319
const errors = checkNode(statement);
321320
if (errors) {

0 commit comments

Comments
 (0)