Skip to content

Commit d7db79b

Browse files
Spencerspalger
authored andcommitted
[dev/build_ts_refs] ignore type checking failures when building ts refs (#93473)
Co-authored-by: spalger <spalger@users.noreply.github.com>
1 parent 5ef8a6f commit d7db79b

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
5959
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
6060
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
61-
"kbn:bootstrap": "node scripts/build_ts_refs",
61+
"kbn:bootstrap": "node scripts/build_ts_refs --ignore-type-failures",
6262
"spec_to_console": "node scripts/spec_to_console",
6363
"storybook": "node scripts/storybook"
6464
},

src/dev/typescript/build_ts_refs_cli.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import { concurrentMap } from './concurrent_map';
1818

1919
const CACHE_WORKING_DIR = Path.resolve(REPO_ROOT, 'data/ts_refs_output_cache');
2020

21+
const TS_ERROR_REF = /\sTS\d{1,6}:\s/;
22+
23+
const isTypeFailure = (error: any) =>
24+
error.exitCode === 1 &&
25+
error.stderr === '' &&
26+
typeof error.stdout === 'string' &&
27+
TS_ERROR_REF.test(error.stdout);
28+
2129
export async function runBuildRefsCli() {
2230
run(
2331
async ({ log, flags }) => {
@@ -48,7 +56,20 @@ export async function runBuildRefsCli() {
4856
await outputCache.initCaches();
4957
}
5058

51-
await buildAllTsRefs(log);
59+
try {
60+
await buildAllTsRefs(log);
61+
log.success('ts refs build successfully');
62+
} catch (error) {
63+
const typeFailure = isTypeFailure(error);
64+
65+
if (flags['ignore-type-failures'] && typeFailure) {
66+
log.warning(
67+
'tsc reported type errors but we are ignoring them for now, to see them please run `node scripts/type_check` or `node scripts/build_ts_refs` without the `--ignore-type-failures` flag.'
68+
);
69+
} else {
70+
throw error;
71+
}
72+
}
5273

5374
if (outputCache && doCapture) {
5475
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
@@ -61,10 +82,15 @@ export async function runBuildRefsCli() {
6182
{
6283
description: 'Build TypeScript projects',
6384
flags: {
64-
boolean: ['clean', 'cache'],
85+
boolean: ['clean', 'cache', 'ignore-type-failures'],
6586
default: {
6687
cache: true,
6788
},
89+
help: `
90+
--clean Delete outDirs for each ts project before building
91+
--no-cache Disable fetching/extracting outDir caches based on the mergeBase with upstream
92+
--ignore-type-failures If tsc reports type errors, ignore them and just log a small warning.
93+
`,
6894
},
6995
log: {
7096
defaultLevel: 'debug',

0 commit comments

Comments
 (0)