deepkit-framework
deepkit-framework copied to clipboard
[Bug] Debugger Fails to Work in a Particular Case
It happens only when:
- database is provided using a class extending
Database
as its token (Database
as token is not tested because the bug) - some entities are inheriting a class and passing some generic type arguments
import { App } from "@deepkit/app";
import { FrameworkModule } from "@deepkit/framework";
import { Database, MemoryDatabaseAdapter } from "@deepkit/orm";
class Entity<T = never> {}
class MyEntity extends Entity<unknown> {} // works when no generic type argument is passed: `extends Entity`
// workaround for the bug that `Database` cannot be used as a token
class DatabaseToken extends Database {}
new App({
imports: [new FrameworkModule({ debug: true })],
providers: [
{
provide: DatabaseToken, // works when the token is not a class extending `Database`
useValue: new Database(new MemoryDatabaseAdapter(), [MyEntity]),
},
],
}).run();
If all the requirements are met, the debugger will fail to work and report a lot of errors:
FrameworkModule
detects databases by tokens, and the debugger replies on the detected databases, which is the reason of why the issue disappears when providing databases using other tokens.
if (isPrototypeOfBase(token, Database)) {
this.dbs.push({ classType: token as ClassType, module });
}