Skip to content

feat: add better typing for conditions in increment and decrement of EntityManager - #11294

Merged
gioboa merged 2 commits into
typeorm:masterfrom
OSA413:fix-10437
Jan 2, 2026
Merged

gioboa merged 2 commits into
typeorm:masterfrom
OSA413:fix-10437

Conversation

@OSA413

@OSA413 OSA413 commented Feb 15, 2025

Copy link
Copy Markdown
Collaborator

Fixes #10437

Description of change

Added types that are directly inherited from the method call, should be no issues.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@coveralls

coveralls commented Feb 15, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 80.909% (+0.001%) from 80.908%
when pulling 32aa51b on OSA413:fix-10437
into f283304 on typeorm:master.

@alumni alumni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good.

Didn't even know increment/decrement existed :)

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Impact
General
Restrict propertyPath to numeric properties

Change the type of the propertyPath parameter in the increment method from
string to PickKeysByType<Entity, number> to ensure it only accepts numeric
properties.

src/entity-manager/EntityManager.ts [1340-1345]

 async increment<Entity extends ObjectLiteral>(
     entityClass: EntityTarget<Entity>,
     conditions: FindOptionsWhere<Entity>,
-    propertyPath: string,
+    propertyPath: PickKeysByType<Entity, number>,
     value: number | string,
 ): Promise<UpdateResult> {
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly improves type safety by restricting the propertyPath to numeric properties, which is consistent with the function's purpose and with other similar methods in the class.

Medium
  • More

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @OSA413

@pkg-pr-new

pkg-pr-new Bot commented Jan 2, 2026

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm/typeorm@11294
    

commit: 32aa51b

@gioboa
gioboa merged commit 2260718 into typeorm:master Jan 2, 2026
Cprakhar pushed a commit to Cprakhar/typeorm that referenced this pull request Jan 7, 2026
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
kranners pushed a commit to kranners/typeorm that referenced this pull request Mar 1, 2026
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

【Important】The ts type prompt issue for EntityManager.increment and EntityManager.decrement!!

5 participants