Skip to content

Conversation

@ulrichstark
Copy link
Contributor

While testing my changes to the @typescript-eslint/no-unnecessary-type-assertion lint rule on this repo, I found these unnecessary type assertions that can be removed without impacting runtime behaviour or triggering TS errors.

typescript-eslint/typescript-eslint#11789

Copilot AI review requested due to automatic review settings January 9, 2026 22:05
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jan 9, 2026
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

1 similar comment
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes unnecessary type assertions across the TypeScript codebase that were identified by improvements to the @typescript-eslint/no-unnecessary-type-assertion lint rule. The changes are purely cosmetic, removing as Type assertions where TypeScript's type inference already provides the correct type information.

Key changes:

  • Removal of redundant type assertions in type guard contexts (e.g., after flags & TypeFlags.TypeParameter checks)
  • Elimination of unnecessary casts where function signatures already accept the broader type
  • Cleanup of assertions where factory methods return the correct specific type

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/testRunner/unittests/tsserver/inlayHints.ts Removed unnecessary assertion on preferences object
src/testRunner/projectsRunner.ts Removed redundant string assertion on baseline content
src/services/symbolDisplay.ts Removed type assertion where type parameter check provides correct type
src/services/stringCompletions.ts Removed host interface assertions where type is already compatible
src/services/services.ts Removed SyntaxKind assertion on Number() result
src/services/getEditsForFileRename.ts Removed ModuleResolutionHost assertion
src/services/findAllReferences.ts Removed assertion on findAncestor result with type guard
src/services/completions.ts Removed ObjectTypeDeclaration assertion on findAncestor
src/services/codefixes/generateAccessors.ts Removed assertion on declaration.name.text
src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts Removed assertion on or() predicate result
src/services/classifier.ts Removed ClassificationType assertion on array access
src/server/utilitiesPublic.ts Removed NormalizedPath[] assertion on concat
src/server/session.ts Removed string assertion on symlinkedPath
src/server/project.ts Removed SortedReadonlyArray assertion on emptyArray
src/server/editorServices.ts Removed ProgramUpdateLevel assertion on Math.max result
src/compiler/utilitiesPublic.ts Removed Identifier assertion where type is already known
src/compiler/utilities.ts Removed NonNullable assertion on generic parameter
src/compiler/tsbuildPublic.ts Removed CompilerHost & ReadBuildProgramHost assertion
src/compiler/transformers/ts.ts Removed ModuleDeclaration assertion after type check
src/compiler/transformers/es2018.ts Removed NodeCheckFlags assertion on literal 0
src/compiler/symbolWalker.ts Removed TypeParameter assertion after flags check
src/compiler/parser.ts Removed callback type assertions for forEachChild
src/compiler/emitter.ts Removed DotToken, Modifier[], and Decorator[] assertions
src/compiler/checker.ts Removed 50+ TypeParameter, UnionType, and other type assertions after flag checks
src/compiler/binder.ts Removed Identifier assertions where function accepts broader Node type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants