mabasic
mabasic5h ago

error[no-slow-types]: super class expression was too complex

I am using Effect, and when I try to lint the codebase I get errors about super classes
x deno lint
error[no-slow-types]: super class expression was too complex
|
7 | extends Schema.TaggedError<FirebaseError>("FirebaseError")("FirebaseError", {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
8 | error: Schema.Unknown,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
9 | }) {}
| ^^^^ this is the superclass expression
|
= hint: extract the superclass expression into a variable

info: fast check was unable to infer the type of the superclass expression
docs: https://jsr.io/go/slow-type-unsupported-super-class-expr
x deno lint
error[no-slow-types]: super class expression was too complex
|
7 | extends Schema.TaggedError<FirebaseError>("FirebaseError")("FirebaseError", {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
8 | error: Schema.Unknown,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
9 | }) {}
| ^^^^ this is the superclass expression
|
= hint: extract the superclass expression into a variable

info: fast check was unable to infer the type of the superclass expression
docs: https://jsr.io/go/slow-type-unsupported-super-class-expr
The code in question is this:
export class FirebaseError
extends Schema.TaggedError<FirebaseError>("FirebaseError")("FirebaseError", {
error: Schema.Unknown,
}) {}
export class FirebaseError
extends Schema.TaggedError<FirebaseError>("FirebaseError")("FirebaseError", {
error: Schema.Unknown,
}) {}
After reading a bit about slow types I am guessing that the type export is too complex to be inferred, and could slow down type checking the code base. The solution is to type the exported things, but I don't know how. In the documentation it says that I should do this: For super class expressions, evaluate the expression and assign it to an intermediate type:
interface ISuperClass {}

function getSuperClass() {
return class SuperClass implements ISuperClass {};
}

- export class MyClass extends getSuperClass() {}
+ const SuperClass: ISuperClass = getSuperClass();
+ export class MyClass extends SuperClass {}
interface ISuperClass {}

function getSuperClass() {
return class SuperClass implements ISuperClass {};
}

- export class MyClass extends getSuperClass() {}
+ const SuperClass: ISuperClass = getSuperClass();
+ export class MyClass extends SuperClass {}
but I don't know how to apply that to Schema.TaggedError. Also, it complains about the same thing for Effect.service
export class Firebase extends Effect.Service<Firebase>()("Firebase", {
effect: Effect.gen(function* () {}){}
export class Firebase extends Effect.Service<Firebase>()("Firebase", {
effect: Effect.gen(function* () {}){}
I can ignore slow types in the config, but that means that by using Effect in packages I am creating slow types all over the place. Any ideas?
2 Replies
marvinh.
marvinh.4h ago
Can you file an issue for that https://github.com/denoland/deno/issues ?
GitHub
denoland/deno
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.

Did you find this page helpful?