From 2b4f459d8bd1ba5167ae5f19007e56336f21d109 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Mon, 29 Jul 2024 15:15:25 -0700 Subject: [PATCH] Fix --- docs/core_docs/scripts/validate_notebook.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/core_docs/scripts/validate_notebook.ts b/docs/core_docs/scripts/validate_notebook.ts index 878af7f607c9..a214420a49a3 100644 --- a/docs/core_docs/scripts/validate_notebook.ts +++ b/docs/core_docs/scripts/validate_notebook.ts @@ -45,6 +45,7 @@ const run = async () => { skipLibCheck: true, }); const diagnostics = ts.getPreEmitDiagnostics(program); + const issueStrings: string[] = []; if (diagnostics.length === 0) { console.log("No type errors found."); } else { @@ -56,18 +57,25 @@ const run = async () => { diagnostic.messageText, "\n" ); - console.log( + issueStrings.push( `${diagnostic.file.fileName} (${line + 1},${ character + 1 }): ${message}` ); } else { - console.log( + issueStrings.push( ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") ); } }); } + if (issueStrings.length) { + const issues = issueStrings.join("\n"); + console.error(issues); + const err = new Error("Found type errors in new notebook:"); + (err as any).details = issues; + throw err; + } } finally { try { fs.rmSync(tempFilepath);