From 933605267cc9da80babde89c10acff3247ebe6b4 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Fri, 23 Feb 2024 10:52:40 -0500 Subject: [PATCH] circularity test is fixed --- .../circularConstructorWithReturn.errors.txt | 31 ------------------- .../circularConstructorWithReturn.types | 22 ++++++------- 2 files changed, 11 insertions(+), 42 deletions(-) delete mode 100644 tests/baselines/reference/circularConstructorWithReturn.errors.txt diff --git a/tests/baselines/reference/circularConstructorWithReturn.errors.txt b/tests/baselines/reference/circularConstructorWithReturn.errors.txt deleted file mode 100644 index ebc91184b55..00000000000 --- a/tests/baselines/reference/circularConstructorWithReturn.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -circularConstructorWithReturn.ts(3,13): error TS2456: Type alias 'Client' circularly references itself. -circularConstructorWithReturn.ts(7,5): error TS2502: 'self' is referenced directly or indirectly in its own type annotation. -circularConstructorWithReturn.ts(16,48): error TS2502: 'client' is referenced directly or indirectly in its own type annotation. - - -==== circularConstructorWithReturn.ts (3 errors) ==== - // This should not be a circularity error. See - // https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216 - export type Client = ReturnType extends new () => infer T ? T : never - ~~~~~~ -!!! error TS2456: Type alias 'Client' circularly references itself. - - export function getPrismaClient(options?: any) { - class PrismaClient { - self: Client; - ~~~~ -!!! error TS2502: 'self' is referenced directly or indirectly in its own type annotation. - constructor(options?: any) { - return (this.self = applyModelsAndClientExtensions(this)); - } - } - - return PrismaClient - } - - export function applyModelsAndClientExtensions(client: Client) { - ~~~~~~~~~~~~~~ -!!! error TS2502: 'client' is referenced directly or indirectly in its own type annotation. - return client; - } - \ No newline at end of file diff --git a/tests/baselines/reference/circularConstructorWithReturn.types b/tests/baselines/reference/circularConstructorWithReturn.types index 72fb4aaa732..53e59755f39 100644 --- a/tests/baselines/reference/circularConstructorWithReturn.types +++ b/tests/baselines/reference/circularConstructorWithReturn.types @@ -4,7 +4,7 @@ // This should not be a circularity error. See // https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216 export type Client = ReturnType extends new () => infer T ? T : never ->Client : any +>Client : PrismaClient >getPrismaClient : (options?: any) => typeof PrismaClient export function getPrismaClient(options?: any) { @@ -15,19 +15,19 @@ export function getPrismaClient(options?: any) { >PrismaClient : PrismaClient self: Client; ->self : any +>self : PrismaClient constructor(options?: any) { >options : any return (this.self = applyModelsAndClientExtensions(this)); ->(this.self = applyModelsAndClientExtensions(this)) : any ->this.self = applyModelsAndClientExtensions(this) : any ->this.self : any +>(this.self = applyModelsAndClientExtensions(this)) : PrismaClient +>this.self = applyModelsAndClientExtensions(this) : PrismaClient +>this.self : PrismaClient >this : this ->self : any ->applyModelsAndClientExtensions(this) : any ->applyModelsAndClientExtensions : (client: any) => any +>self : PrismaClient +>applyModelsAndClientExtensions(this) : PrismaClient +>applyModelsAndClientExtensions : (client: PrismaClient) => PrismaClient >this : this } } @@ -37,10 +37,10 @@ export function getPrismaClient(options?: any) { } export function applyModelsAndClientExtensions(client: Client) { ->applyModelsAndClientExtensions : (client: any) => any ->client : any +>applyModelsAndClientExtensions : (client: Client) => PrismaClient +>client : PrismaClient return client; ->client : any +>client : PrismaClient }