From d71d0d1b8478b8a6cefa102b06dd5cf3d2365703 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 27 Apr 2026 15:50:58 +0200 Subject: [PATCH] Refine type lookup in getRootType function --- scripts/list-authorable-fields.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/list-authorable-fields.ts b/scripts/list-authorable-fields.ts index 0f4b2edb..fded23da 100644 --- a/scripts/list-authorable-fields.ts +++ b/scripts/list-authorable-fields.ts @@ -168,22 +168,22 @@ function getRootType(root: AuthorableRoot): ts.Type { throw new Error(`Could not load ${root.file}.`); } - let foundNode: ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null = null; + let foundName: ts.Identifier | null = null; ts.forEachChild(sourceFile, (node) => { if ( (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) && node.name.text === root.typeName ) { - foundNode = node; + foundName = node.name; } }); - if (foundNode === null) { + if (foundName === null) { throw new Error(`Could not find ${root.typeName} in ${root.file}.`); } - return checker.getTypeAtLocation(foundNode.name); + return checker.getTypeAtLocation(foundName); } function withoutNullish(type: ts.Type): ts.Type {