Open bozmen opened 1 year ago
Crash is caused by an infinite inference loop - when inferring the reverse mapped type between SchemaDefinitionProperty<undefined>
(from mongoose
) and Schema<T[key]>
(a type made in the repro) we perform subtype reduction on the inference result (which is itself a bunch of reverse Schema
mapped types over the various schema types), which, in turn, requests that we infer the reverse mapped type between SchemaDefinitionProperty<undefined>
and Schema<T[key][key]>
, which in turn... Yeah. We're pulling on the structure a bit too eagerly, causing us to go infinite. I can rework a perf improvement I made awhile back to give use a place to bail on the recursion, which should fix the issue, but it's a bit of an open question if we want it to error (and if so: where?), or would rather silently proceed despite the cut recursion (similarly to how recursive class references can work, but can result in some calculations witnessing unfinished type structure and thus producing inaccurate results).
Bug Report
🔎 Search Terms
tsc: RangeError: Maximum call stack size exceeded
🕗 Version & Regression Information
⏯ Playground Link
https://github.com/Klab-Berlin/mongoose-test
💻 Code
tsconfig.json
🙁 Actual behavior
When we try to compile our code with tsc and with the given tsconfig file, we get the error
tsc: RangeError: Maximum call stack size exceeded
.The whole error log:
🙂 Expected behavior
We expect to be able to compile this code. Not really sure if there is a problem with out types.