Skip to content

Commit f5b93c1

Browse files
authored
refactor: query methods should accept generic for return type (#9957)
* query should accept generics * Update DataSource.ts
1 parent 0e56f0f commit f5b93c1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/data-source/DataSource.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ export class DataSource {
515515
/**
516516
* Executes raw SQL query and returns raw database results.
517517
*/
518-
async query(
518+
async query<T = any>(
519519
query: string,
520520
parameters?: any[],
521521
queryRunner?: QueryRunner,
522-
): Promise<any> {
522+
): Promise<T> {
523523
if (InstanceChecker.isMongoEntityManager(this.manager))
524524
throw new TypeORMError(`Queries aren't supported by MongoDB.`)
525525

src/entity-manager/EntityManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class EntityManager {
170170
/**
171171
* Executes raw SQL query and returns raw database results.
172172
*/
173-
async query(query: string, parameters?: any[]): Promise<any> {
173+
async query<T = any>(query: string, parameters?: any[]): Promise<T> {
174174
return this.connection.query(query, parameters, this.queryRunner)
175175
}
176176

0 commit comments

Comments
 (0)