FG
🗄️ Databases

Why was the custom repository syntax changed?

Fresh6 months ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

I'm currently migrating from 0.2 to 0.3 and noticed that the syntax for custom repository was changed. I personally find this change very odd but I assume typeorm devs have a perfectly fine explanation for this - I lack to find it though. Remark: I know that this issue is not a documentation issue per se but SO is not the place to discuss things that's why I decided to post it here. Where I'm coming from: My project only uses a single relational database with various small custom repositories. Here is a simple example repository from 0.2: import {User} from "../bl/user"; import {EntityManager, EntityRepository, Repository} from "typeorm"; @EntityRepository(User) export class UserRepository extends Repository<User> { findByEmail(email: string): Promise<User | undefined> { // Implementation not relevant } isEmailAlreadyInUser(email: string): Promise<boolean> { // Implementation not relevant } } export function getUserRepository(manager: EntityManager): UserRepository { return manager.getCustomRepository(UserRepository); } New 0.3 version: // I have to manually create a type so UserRepository exists in type space. export type UserRepositoryType = Repository<User> & { findByEmail(email: string): Promise<User | null>; isEmailAlreadyInUser(email: string): Promise<boolean>; } // this UserRepository only exists in value space. Without my previous type

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
78% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: Why was the custom repository syntax changed?

Low Risk

I found a way on how to implement custom repositories with the new version. I answered this question on Stack Overflow. Maybe this might help someone: https://stackoverflow.com/questions/72549668/how-to-do-custom-repository-using-typeorm-mongodb-in-nestjs/72887316#72887316

78

Trust Score

6 verifications

100% success
  1. 1

    I found a way on how to implement custom repositories with the new version. I an

    I found a way on how to implement custom repositories with the new version. I answered this question on Stack Overflow. Maybe this might help someone: https://stackoverflow.com/questions/72549668/how-to-do-custom-repository-using-typeorm-mongodb-in-nestjs/72887316#72887316

Validation

Resolved in typeorm/typeorm GitHub issue #9013. Community reactions: 18 upvotes.

Verification Summary

Worked: 6
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typeormormtypescriptdocumentationrequires-triagestale