Skip to content

Commit 3279a2b

Browse files
committed
run buildRefs before type check to ensure the latest version
1 parent 50bdcd8 commit 3279a2b

4 files changed

Lines changed: 62 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@
6464
"uiFramework:createComponent": "cd packages/kbn-ui-framework && yarn createComponent",
6565
"uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent",
6666
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
67-
"build:refs": "tsc -b tsconfig.refs.json",
6867
"build:types": "tsc --p tsconfig.types.json",
6968
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
70-
"kbn:bootstrap": "yarn build:refs && node scripts/register_git_hook",
69+
"kbn:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook",
7170
"spec_to_console": "node scripts/spec_to_console",
7271
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
7372
"storybook": "node scripts/storybook",

scripts/build_ts_refs.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
require('../src/setup_node_env');
20+
require('../src/dev/typescript/build_refs').runBuildRefs();

src/dev/typescript/build_refs.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import execa from 'execa';
21+
import { run, ToolingLog } from '@kbn/dev-utils';
22+
23+
export async function buildRefs(log: ToolingLog) {
24+
try {
25+
log.info('Building TypeScript projects refs...');
26+
await execa(require.resolve('typescript/bin/tsc'), ['-b', 'tsconfig.refs.json']);
27+
} catch (e) {
28+
log.error(e);
29+
process.exit(1);
30+
}
31+
}
32+
33+
export async function runBuildRefs() {
34+
run(async ({ log }) => {
35+
await buildRefs(log);
36+
});
37+
}

src/dev/typescript/run_type_check_cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import getopts from 'getopts';
2424

2525
import { execInProjects } from './exec_in_projects';
2626
import { filterProjectsByFlag } from './projects';
27+
import { buildRefs } from './build_refs';
2728

28-
export function runTypeCheckCli() {
29+
export async function runTypeCheckCli() {
2930
const extraFlags: string[] = [];
3031
const opts = getopts(process.argv.slice(2), {
3132
boolean: ['skip-lib-check', 'help'],
@@ -79,6 +80,8 @@ export function runTypeCheckCli() {
7980
process.exit();
8081
}
8182

83+
await buildRefs(log);
84+
8285
const tscArgs = [
8386
// composite project cannot be used with --noEmit
8487
...['--composite', 'false'],

0 commit comments

Comments
 (0)