Fix tsc errors

This commit is contained in:
Jonathan Tran
2025-04-04 15:51:19 -04:00
parent 4010c3f961
commit b228aaae45
2 changed files with 28 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import type { Node } from '@rust/kcl-lib/bindings/Node'
import { NonCodeMeta } from '@rust/kcl-lib/bindings/NonCodeMeta'
import { type NonCodeMeta } from '@rust/kcl-lib/bindings/NonCodeMeta'
import {
ARG_ANGLE,
@ -74,7 +74,7 @@ import type {
} from '@src/lang/wasm'
import { sketchFromKclValue } from '@src/lang/wasm'
import type { Selections } from '@src/lib/selections'
import { cleanErrs, err } from '@src/lib/trap'
import { cleanErrs, err, isNotErr } from '@src/lib/trap'
import {
allLabels,
getAngle,
@ -1501,16 +1501,34 @@ export function removeSingleConstraint({
)
}
const toReplace = inputToReplace.key
const args = inputs.map((arg) => {
let argsPreFilter = inputs.map((arg) => {
// console.log('ADAM: arg is', arg)
if (arg.type !== 'labeledArg') {
return undefined
}
const k = arg.key
if (k !== toReplace) {
return createLabeledArg(k, arg.expr)
} else {
const rawArgVersion = rawArgs.find((a) => a.key === k)
const rawArgVersion = rawArgs.find(
(a) => a.type === 'labeledArg' && a.key === k
)
if (!rawArgVersion) {
return new Error(
`raw arg version not found while trying to remove constraint: ${JSON.stringify(arg)}`
)
}
return createLabeledArg(k, rawArgVersion.expr)
}
})
const args = argsPreFilter
.filter((arg) => arg !== undefined)
.filter(isNotErr)
if (args.length !== argsPreFilter.length) {
return new Error('Error while trying to remove constraint', {
cause: argsPreFilter,
})
}
const noncode = callExp.node.nonCodeMeta
return createStdlibCallExpressionKw(
callExp.node.callee.name.name as ToolTip,

View File

@ -19,6 +19,12 @@ export class Reason {
}
}
export function isNotErr<T>(
value: ExcludeErr<T> | Error
): value is ExcludeErr<T> {
return !(value instanceof Error)
}
/**
* This is intentionally *not* exported due to misuse. We'd like to add a lint.
*/