Skip to content

Commit 79da16c

Browse files
fix(deps): update dependency ts-pattern to v5.7.1 (#1000)
Signed-off-by: Louis Mandel <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Louis Mandel <[email protected]>
1 parent bf0100f commit 79da16c

File tree

4 files changed

+44
-37
lines changed

4 files changed

+44
-37
lines changed

pdl-live-react/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdl-live-react/src/pdl_ast_utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export function map_block_children(
4545
)
4646
new_block = { ...new_block, contribute }
4747
}
48-
// @ts-expect-error: TODO
4948
new_block = match(new_block)
5049
// .with(P.string, s => s)
5150
.with({ kind: "empty" }, (block) => block)
@@ -202,7 +201,8 @@ export function map_block_children(
202201
})
203202
.with({ kind: "include" }, (block) => block)
204203
.with({ kind: "import" }, (block) => block)
205-
.with({ kind: undefined }, (block) => block)
204+
.with({ kind: P.nullish }, (block) => block)
205+
// @ts-expect-error: TODO
206206
.exhaustive()
207207
match(new_block)
208208
.with({ parser: { pdl: P._ } }, (block) => {
@@ -294,6 +294,7 @@ export function iter_block_children(
294294
.with({ kind: "include" }, () => {})
295295
.with({ kind: "import" }, () => {})
296296
.with({ kind: undefined }, () => {})
297+
// @ts-expect-error: TODO
297298
.exhaustive()
298299
match(block)
299300
.with({ parser: { pdl: P._ } }, (block) => {

pdl-live-react/src/view/detail/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function find(
2121
} else {
2222
return (
2323
childrenOf(block)
24-
.map((child) => find(child, id))
24+
.map((child: Block) => find(child, id))
2525
.filter(nonNullable)[0] || null
2626
)
2727
}

pdl-live-react/src/view/timeline/model.ts

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ function computeModelIter(
102102

103103
const childrenModel = childrenOf(block)
104104
.filter(nonNullable)
105-
.flatMap((child) => computeModelIter(child, root))
105+
.flatMap((child: PdlBlock) => computeModelIter(child, root))
106106

107107
// Correct for anomalies in the trace where a child may have an
108108
// earlier end timestamp than its children. See
109109
// https://github.com/IBM/prompt-declaration-language/pull/683
110110
if (root) {
111111
const maxEnd = childrenModel.reduce(
112-
(maxEnd, child) => Math.max(maxEnd, child.block.pdl__timing.end_nanos),
112+
(maxEnd: number, child: TimelineRow) =>
113+
Math.max(maxEnd, child.block.pdl__timing.end_nanos),
113114
0,
114115
)
115116
root.block.pdl__timing.end_nanos = Math.max(
@@ -122,35 +123,40 @@ function computeModelIter(
122123
}
123124

124125
export function childrenOf(block: NonScalarPdlBlock) {
125-
return match(block)
126-
.with({ kind: "model" }, (data) => [/*data.input,*/ data.pdl__result])
127-
.with({ kind: "code" }, (data) => [data.pdl__result])
128-
.with({ kind: "get" }, (data) => [data.pdl__result])
129-
.with({ kind: "data" }, (data) => [data.pdl__result])
130-
.with({ kind: "if", if: { pdl__result: P._ } }, (data) =>
131-
data.if.pdl__result ? [data.then] : [data.else],
132-
)
133-
.with({ kind: "if" }, (data) => [data.then, data.else])
134-
.with({ kind: "match" }, (data) => [data.with]) // TODO
135-
.with({ kind: "read" }, (data) => [data.pdl__result])
136-
.with({ kind: "include" }, (data) => [data.pdl__trace ?? data.pdl__result])
137-
.with({ kind: "import" }, (data) => [data.pdl__trace ?? data.pdl__result])
138-
.with({ kind: "function" }, () => [])
139-
.with({ kind: "call" }, (data) => [data.pdl__trace ?? data.pdl__result])
140-
.with({ kind: "text" }, (data) => [data.text])
141-
.with({ kind: "lastOf" }, (data) => [data.lastOf])
142-
.with({ kind: "array" }, (data) => [data.array])
143-
.with({ kind: "object" }, (data) => [data.object])
144-
.with({ kind: "message" }, (data) => [data.content])
145-
.with({ kind: "repeat" }, (data) => [data.pdl__trace ?? data.repeat])
146-
.with({ kind: "empty" }, (data) =>
147-
data.defs ? Object.values(data.defs) : [],
148-
)
149-
.with({ kind: "error" }, () => []) // TODO show errors in trace
150-
.with({ kind: undefined }, () => [])
151-
.exhaustive()
152-
.flat()
153-
.filter(nonNullable)
126+
return (
127+
match(block)
128+
.with({ kind: "model" }, (data) => [/*data.input,*/ data.pdl__result])
129+
.with({ kind: "code" }, (data) => [data.pdl__result])
130+
.with({ kind: "get" }, (data) => [data.pdl__result])
131+
.with({ kind: "data" }, (data) => [data.pdl__result])
132+
.with({ kind: "if", if: { pdl__result: P._ } }, (data) =>
133+
data.if.pdl__result ? [data.then] : [data.else],
134+
)
135+
.with({ kind: "if" }, (data) => [data.then, data.else])
136+
.with({ kind: "match" }, (data) => [data.with]) // TODO
137+
.with({ kind: "read" }, (data) => [data.pdl__result])
138+
.with({ kind: "include" }, (data) => [
139+
data.pdl__trace ?? data.pdl__result,
140+
])
141+
.with({ kind: "import" }, (data) => [data.pdl__trace ?? data.pdl__result])
142+
.with({ kind: "function" }, () => [])
143+
.with({ kind: "call" }, (data) => [data.pdl__trace ?? data.pdl__result])
144+
.with({ kind: "text" }, (data) => [data.text])
145+
.with({ kind: "lastOf" }, (data) => [data.lastOf])
146+
.with({ kind: "array" }, (data) => [data.array])
147+
.with({ kind: "object" }, (data) => [data.object])
148+
.with({ kind: "message" }, (data) => [data.content])
149+
.with({ kind: "repeat" }, (data) => [data.pdl__trace ?? data.repeat])
150+
.with({ kind: "empty" }, (data) =>
151+
data.defs ? Object.values(data.defs) : [],
152+
)
153+
.with({ kind: "error" }, () => []) // TODO show errors in trace
154+
.with({ kind: undefined }, () => [])
155+
// @ts-expect-error: TODO
156+
.exhaustive()
157+
.flat()
158+
.filter(nonNullable)
159+
)
154160
}
155161

156162
function positionOf(row: TimelineRow): Position {

0 commit comments

Comments
 (0)