mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-23 18:48:40 -05:00
add prisma circularity test with failing baseline
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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<typeof getPrismaClient> 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;
|
||||
}
|
||||
|
||||
41
tests/baselines/reference/circularConstructorWithReturn.js
Normal file
41
tests/baselines/reference/circularConstructorWithReturn.js
Normal file
@@ -0,0 +1,41 @@
|
||||
//// [tests/cases/compiler/circularConstructorWithReturn.ts] ////
|
||||
|
||||
//// [circularConstructorWithReturn.ts]
|
||||
// This should not be a circularity error. See
|
||||
// https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216
|
||||
export type Client = ReturnType<typeof getPrismaClient> extends new () => infer T ? T : never
|
||||
|
||||
export function getPrismaClient(options?: any) {
|
||||
class PrismaClient {
|
||||
self: Client;
|
||||
constructor(options?: any) {
|
||||
return (this.self = applyModelsAndClientExtensions(this));
|
||||
}
|
||||
}
|
||||
|
||||
return PrismaClient
|
||||
}
|
||||
|
||||
export function applyModelsAndClientExtensions(client: Client) {
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
//// [circularConstructorWithReturn.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.applyModelsAndClientExtensions = exports.getPrismaClient = void 0;
|
||||
function getPrismaClient(options) {
|
||||
var PrismaClient = /** @class */ (function () {
|
||||
function PrismaClient(options) {
|
||||
return (this.self = applyModelsAndClientExtensions(this));
|
||||
}
|
||||
return PrismaClient;
|
||||
}());
|
||||
return PrismaClient;
|
||||
}
|
||||
exports.getPrismaClient = getPrismaClient;
|
||||
function applyModelsAndClientExtensions(client) {
|
||||
return client;
|
||||
}
|
||||
exports.applyModelsAndClientExtensions = applyModelsAndClientExtensions;
|
||||
@@ -0,0 +1,48 @@
|
||||
//// [tests/cases/compiler/circularConstructorWithReturn.ts] ////
|
||||
|
||||
=== circularConstructorWithReturn.ts ===
|
||||
// This should not be a circularity error. See
|
||||
// https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216
|
||||
export type Client = ReturnType<typeof getPrismaClient> extends new () => infer T ? T : never
|
||||
>Client : Symbol(Client, Decl(circularConstructorWithReturn.ts, 0, 0))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>getPrismaClient : Symbol(getPrismaClient, Decl(circularConstructorWithReturn.ts, 2, 93))
|
||||
>T : Symbol(T, Decl(circularConstructorWithReturn.ts, 2, 79))
|
||||
>T : Symbol(T, Decl(circularConstructorWithReturn.ts, 2, 79))
|
||||
|
||||
export function getPrismaClient(options?: any) {
|
||||
>getPrismaClient : Symbol(getPrismaClient, Decl(circularConstructorWithReturn.ts, 2, 93))
|
||||
>options : Symbol(options, Decl(circularConstructorWithReturn.ts, 4, 32))
|
||||
|
||||
class PrismaClient {
|
||||
>PrismaClient : Symbol(PrismaClient, Decl(circularConstructorWithReturn.ts, 4, 48))
|
||||
|
||||
self: Client;
|
||||
>self : Symbol(PrismaClient.self, Decl(circularConstructorWithReturn.ts, 5, 22))
|
||||
>Client : Symbol(Client, Decl(circularConstructorWithReturn.ts, 0, 0))
|
||||
|
||||
constructor(options?: any) {
|
||||
>options : Symbol(options, Decl(circularConstructorWithReturn.ts, 7, 16))
|
||||
|
||||
return (this.self = applyModelsAndClientExtensions(this));
|
||||
>this.self : Symbol(PrismaClient.self, Decl(circularConstructorWithReturn.ts, 5, 22))
|
||||
>this : Symbol(PrismaClient, Decl(circularConstructorWithReturn.ts, 4, 48))
|
||||
>self : Symbol(PrismaClient.self, Decl(circularConstructorWithReturn.ts, 5, 22))
|
||||
>applyModelsAndClientExtensions : Symbol(applyModelsAndClientExtensions, Decl(circularConstructorWithReturn.ts, 13, 1))
|
||||
>this : Symbol(PrismaClient, Decl(circularConstructorWithReturn.ts, 4, 48))
|
||||
}
|
||||
}
|
||||
|
||||
return PrismaClient
|
||||
>PrismaClient : Symbol(PrismaClient, Decl(circularConstructorWithReturn.ts, 4, 48))
|
||||
}
|
||||
|
||||
export function applyModelsAndClientExtensions(client: Client) {
|
||||
>applyModelsAndClientExtensions : Symbol(applyModelsAndClientExtensions, Decl(circularConstructorWithReturn.ts, 13, 1))
|
||||
>client : Symbol(client, Decl(circularConstructorWithReturn.ts, 15, 47))
|
||||
>Client : Symbol(Client, Decl(circularConstructorWithReturn.ts, 0, 0))
|
||||
|
||||
return client;
|
||||
>client : Symbol(client, Decl(circularConstructorWithReturn.ts, 15, 47))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/circularConstructorWithReturn.ts] ////
|
||||
|
||||
=== circularConstructorWithReturn.ts ===
|
||||
// This should not be a circularity error. See
|
||||
// https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216
|
||||
export type Client = ReturnType<typeof getPrismaClient> extends new () => infer T ? T : never
|
||||
>Client : any
|
||||
>getPrismaClient : (options?: any) => typeof PrismaClient
|
||||
|
||||
export function getPrismaClient(options?: any) {
|
||||
>getPrismaClient : (options?: any) => typeof PrismaClient
|
||||
>options : any
|
||||
|
||||
class PrismaClient {
|
||||
>PrismaClient : PrismaClient
|
||||
|
||||
self: Client;
|
||||
>self : any
|
||||
|
||||
constructor(options?: any) {
|
||||
>options : any
|
||||
|
||||
return (this.self = applyModelsAndClientExtensions(this));
|
||||
>(this.self = applyModelsAndClientExtensions(this)) : any
|
||||
>this.self = applyModelsAndClientExtensions(this) : any
|
||||
>this.self : any
|
||||
>this : this
|
||||
>self : any
|
||||
>applyModelsAndClientExtensions(this) : any
|
||||
>applyModelsAndClientExtensions : (client: any) => any
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
return PrismaClient
|
||||
>PrismaClient : typeof PrismaClient
|
||||
}
|
||||
|
||||
export function applyModelsAndClientExtensions(client: Client) {
|
||||
>applyModelsAndClientExtensions : (client: any) => any
|
||||
>client : any
|
||||
|
||||
return client;
|
||||
>client : any
|
||||
}
|
||||
|
||||
18
tests/cases/compiler/circularConstructorWithReturn.ts
Normal file
18
tests/cases/compiler/circularConstructorWithReturn.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// This should not be a circularity error. See
|
||||
// https://github.com/microsoft/TypeScript/pull/57465#issuecomment-1960271216
|
||||
export type Client = ReturnType<typeof getPrismaClient> extends new () => infer T ? T : never
|
||||
|
||||
export function getPrismaClient(options?: any) {
|
||||
class PrismaClient {
|
||||
self: Client;
|
||||
constructor(options?: any) {
|
||||
return (this.self = applyModelsAndClientExtensions(this));
|
||||
}
|
||||
}
|
||||
|
||||
return PrismaClient
|
||||
}
|
||||
|
||||
export function applyModelsAndClientExtensions(client: Client) {
|
||||
return client;
|
||||
}
|
||||
Reference in New Issue
Block a user