diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2025-11-05 01:20:07 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2025-11-06 20:28:00 -0800 |
| commit | d8a969e231135978c4dd1fa67559101f506ad6f3 (patch) | |
| tree | 7a556db33abe541fa3f5902690ca93d782c0ecc7 /src/lang/ts-lang/core/common.ts | |
| parent | e86c68dffaffee6ba44d98ba06761245f6d5b670 (diff) | |
recursion works for types with depth limit 5
Diffstat (limited to 'src/lang/ts-lang/core/common.ts')
| -rw-r--r-- | src/lang/ts-lang/core/common.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lang/ts-lang/core/common.ts b/src/lang/ts-lang/core/common.ts index fa5cb7c..95a9ad3 100644 --- a/src/lang/ts-lang/core/common.ts +++ b/src/lang/ts-lang/core/common.ts @@ -51,16 +51,20 @@ export type ParserCtx = { }; export type StackFrame< - Bindings extends Record<ASTNode["name"], any> = Record<ASTNode["name"], any>, - Parent extends StackFrame | null = any + Bindings extends Record<ASTNode["name"], any> = Record<ASTNode["name"], any> > = { bindings: Bindings; - parent: Parent; }; -export type EmptyStackFrame = StackFrame<{}, null>; +export type EmptyStackFrame = StackFrame<{}>; -export type WithPushedBindings< +export type MergeStackFrames< OldFrame extends StackFrame, - Bindings extends StackFrame["bindings"] -> = StackFrame<Bindings, OldFrame>; + NewFrame extends StackFrame +> = StackFrame<{ + [K in + | keyof OldFrame["bindings"] + | keyof NewFrame["bindings"]]: K extends keyof NewFrame["bindings"] + ? NewFrame["bindings"][K] + : OldFrame["bindings"][K]; +}>; |
