diff --git a/src/validator.ts b/src/validator.ts index 8a62c9a9..f5dd1fdb 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -83,9 +83,9 @@ const error = problem('error') // VALIDATION MESSAGES // ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════ -const valuesForNodeName = (node: { name: string}) => [node.name ?? ''] +const valuesForNodeName = (node: { name?: string }) => [node.name ?? ''] -const sourceMapForNodeName = (node: Node & { name: string }) => { +const sourceMapForNodeName = (node: Node & { name?: string }) => { if (!node.sourceMap) return undefined const nodeOffset = getOffsetForName(node) return node.sourceMap && new SourceMap({ @@ -125,7 +125,7 @@ export const nameShouldBeginWithLowercase = nameMatches(/^[a-z_<]/) export const nameShouldNotBeKeyword = error(node => !RESERVED_WORDS.includes(node.name || ''), -node => [node.name ?? ''], +valuesForNodeName, sourceMapForNodeName, ) @@ -299,7 +299,9 @@ export const parameterShouldNotDuplicateExistingVariable = error(node export const shouldNotDuplicateLocalVariables = error(node => !duplicatesLocalVariable(node), valuesForNodeName, sourceMapForNodeName) export const shouldNotDuplicateGlobalDefinitions = error(node => - !node.name || !node.parent.is(Package) || isEmpty(node.siblings().filter(child => (child as Entity).name == node.name)) + !node.name || !node.parent.is(Package) || isEmpty(node.siblings().filter(child => (child as Entity).name == node.name)), +valuesForNodeName, +sourceMapForNodeName, ) export const shouldNotDuplicateVariablesInLinearization = error(node => {