Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev/build_ts_refs] ignore type checking failures when building ts refs #93473

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"kbn:bootstrap": "node scripts/build_ts_refs",
"kbn:bootstrap": "node scripts/build_ts_refs --ignore-type-failures",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"storybook": "node scripts/storybook",
Expand Down
30 changes: 28 additions & 2 deletions src/dev/typescript/build_ts_refs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ import { concurrentMap } from './concurrent_map';

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

const TS_ERROR_REF = /\sTS\d{1,6}:\s/;

const isTypeFailure = (error: any) =>
error.exitCode === 1 &&
error.stderr === '' &&
typeof error.stdout === 'string' &&
TS_ERROR_REF.test(error.stdout);

export async function runBuildRefsCli() {
run(
async ({ log, flags }) => {
Expand Down Expand Up @@ -48,7 +56,20 @@ export async function runBuildRefsCli() {
await outputCache.initCaches();
}

await buildAllTsRefs(log);
try {
await buildAllTsRefs(log);
log.success('ts refs build successfully');
} catch (error) {
const typeFailure = isTypeFailure(error);

if (flags['ignore-type-failures'] && typeFailure) {
log.warning(
'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.'
);
} else {
throw error;
}
}

if (outputCache && doCapture) {
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
Expand All @@ -61,10 +82,15 @@ export async function runBuildRefsCli() {
{
description: 'Build TypeScript projects',
flags: {
boolean: ['clean', 'cache'],
boolean: ['clean', 'cache', 'ignore-type-failures'],
default: {
cache: true,
},
help: `
--clean Delete outDirs for each ts project before building
--no-cache Disable fetching/extracting outDir caches based on the mergeBase with upstream
--ignore-type-failures If tsc reports type errors, ignore them and just log a small warning.
`,
},
log: {
defaultLevel: 'debug',
Expand Down