Summary
packages/editor/src/components/tools/shared/pointer-support-cap.ts only
type-checks when the consuming project enables noUncheckedIndexedAccess.
const belongsToActiveLevel = (nodeId: AnyNodeId) => {
let current = nodes[nodeId] // inferred as AnyNode (no `| undefined`)
const visited = new Set<AnyNodeId>()
while (current && !visited.has(current.id)) {
if (current.id === levelId) return true
visited.add(current.id)
current = current.parentId ? nodes[current.parentId as AnyNodeId] : undefined
// ^^^^^^^^^
}
return false
}
With noUncheckedIndexedAccess: true (which the project itself uses) the
initializer is AnyNode | undefined and the assignment is fine. With the flag
off — a common, perfectly valid strict setup — the variable is inferred as
AnyNode and assigning undefined fails:
node_modules/@pascal-app/editor/src/components/tools/shared/pointer-support-cap.ts(166,9):
error TS2322: Type '... | undefined' is not assignable to type '...'.
The package ships TypeScript sources, so consumers type-check them. Turning on
noUncheckedIndexedAccess project-wide just to build a dependency isn't a fair
ask — it's a rule about all of the consumer's own code.
Suggested fix
Annotate the variable explicitly, which is correct under both settings:
let current: AnyNode | undefined = nodes[nodeId]
(AnyNode is already exported from @pascal-app/core.)
Version
@pascal-app/editor@1.0.0-beta.4
Summary
packages/editor/src/components/tools/shared/pointer-support-cap.tsonlytype-checks when the consuming project enables
noUncheckedIndexedAccess.With
noUncheckedIndexedAccess: true(which the project itself uses) theinitializer is
AnyNode | undefinedand the assignment is fine. With the flagoff — a common, perfectly valid
strictsetup — the variable is inferred asAnyNodeand assigningundefinedfails:The package ships TypeScript sources, so consumers type-check them. Turning on
noUncheckedIndexedAccessproject-wide just to build a dependency isn't a fairask — it's a rule about all of the consumer's own code.
Suggested fix
Annotate the variable explicitly, which is correct under both settings:
(
AnyNodeis already exported from@pascal-app/core.)Version
@pascal-app/editor@1.0.0-beta.4