Skip to content

Remove unnecessary annotations/casts/aliases #46727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43062,8 +43062,7 @@ namespace ts {

// Modifiers are never allowed on properties except for 'async' on a method declaration
if (prop.modifiers) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
for (const mod of prop.modifiers!) { // TODO: GH#19955
for (const mod of prop.modifiers) {
if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) {
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
}
Expand Down
4 changes: 1 addition & 3 deletions src/services/codefixes/convertToEsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ namespace ts.codefix {
const importSpecifiers = mapAllOrFail(name.elements, e =>
e.dotDotDotToken || e.initializer || e.propertyName && !isIdentifier(e.propertyName) || !isIdentifier(e.name)
? undefined
// (TODO: GH#18217)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
: makeImportSpecifier(e.propertyName && (e.propertyName as Identifier).text, e.name.text));
: makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text));
if (importSpecifiers) {
return convertedImports([makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ namespace ts.FindAllReferences {
if (!symbol) return undefined;
for (const token of getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer)) {
if (!isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) continue;
const referenceSymbol: Symbol = checker.getSymbolAtLocation(token)!; // See GH#19955 for why the type annotation is necessary
const referenceSymbol = checker.getSymbolAtLocation(token)!;
if (referenceSymbol === symbol
|| checker.getShorthandAssignmentValueSymbol(token.parent) === symbol
|| isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) {
Expand Down
3 changes: 1 addition & 2 deletions src/services/refactors/extractSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ namespace ts.refactor.extractSymbol {
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
const statements: Statement[] = [];
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
for (const statement of (start2.parent as BlockLike).statements) {
for (const statement of start.parent.statements) {
if (statement === start || statements.length) {
const errors = checkNode(statement);
if (errors) {
Expand Down