-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
π Search Terms
RangeError: Maximum call stack size exceeded, #52392
π Version & Regression Information
- This changed in commit or PR Consistently propagate
intersectionState
in relationsΒ #52392
β― Playground Link
π» Code
export {};
declare abstract class TypeDataModel<Parent> {
parent: Parent;
prepareDerivedData(
this: this extends { parent: infer _ } ? never : never
): void;
}
declare class BaseItem extends Document<any> {
parent: BaseItem.Parent;
}
declare namespace BaseItem {
type Parent = typeof ActorPTR2e;
}
declare global {
namespace foundry {
export import _Unused = BaseItem;
}
}
declare class Item extends Document {}
declare class FolderPTR2e {
x: typeof ActorPTR2e;
}
declare class ActorPTR2e {
y: typeof FolderPTR2e;
z: TypeDataModel<typeof Item>;
}
type DeepPartial<T extends object> = {
[K in keyof T]?: _DeepPartial<T[K]>;
};
type _DeepPartial<T> = T extends object ? DeepPartial<T> : T;
declare class DocumentSheetV2<Document, Configuration extends object = any> {
constructor(
options: DeepPartial<Configuration> & {
document: Document;
}
);
}
declare const folder: typeof FolderPTR2e;
new DocumentSheetV2({ document: folder });
π Actual behavior
The compiler crashes with RangeError: Maximum call stack size exceeded
.
RangeError: Maximum call stack size exceeded
at structuredTypeRelatedToWorker (node_modules/typescript/lib/_tsc.js:64885:43)
at structuredTypeRelatedTo (node_modules/typescript/lib/_tsc.js:64817:21)
at recursiveTypeRelatedTo (node_modules/typescript/lib/_tsc.js:64768:19)
at isRelatedTo (node_modules/typescript/lib/_tsc.js:64186:122)
at isPropertySymbolTypeRelated (node_modules/typescript/lib/_tsc.js:65563:14)
at propertyRelatedTo (node_modules/typescript/lib/_tsc.js:65603:23)
at propertiesRelatedTo (node_modules/typescript/lib/_tsc.js:65814:29)
at structuredTypeRelatedToWorker (node_modules/typescript/lib/_tsc.js:65361:21)
at structuredTypeRelatedTo (node_modules/typescript/lib/_tsc.js:64817:21)
at recursiveTypeRelatedTo (node_modules/typescript/lib/_tsc.js:64768:19)
(this is on 5.8.0-dev.20250106 but the same error appears on 5.7.2 and several other versions I tested as well as all the ones I bisected)
π Expected behavior
Regular errors. This file has a few but in my original repo there were less, possibly none?
The editor doesn't crash and reports these errors:
Type instantiation is excessively deep and possibly infinite.
Expression produces a union type that is too complex to represent.
On DocumentSheetV2
. I find the second one odd because there's not a single union in the program.
There's also the error:
No base constructor has the specified number of type arguments.
On Document<any>
, because Document
doesn't take type arguments. In my original repo I wasn't passing a generic to a class without one but this was the easiest way to reliably reproduce it. I can get it to work without the <any>
but it was simply less reliable while I was reducing so I left it in.
Additional information about the issue
No response