diff --git a/examples/bfetch_explorer/tsconfig.json b/examples/bfetch_explorer/tsconfig.json index 86b35c5e4943f..253fdd9ee6c89 100644 --- a/examples/bfetch_explorer/tsconfig.json +++ b/examples/bfetch_explorer/tsconfig.json @@ -13,6 +13,7 @@ ], "exclude": [], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/examples/embeddable_examples/tsconfig.json b/examples/embeddable_examples/tsconfig.json index 78098339c16f5..a922c6defcd4c 100644 --- a/examples/embeddable_examples/tsconfig.json +++ b/examples/embeddable_examples/tsconfig.json @@ -14,6 +14,7 @@ ], "exclude": [], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/examples/state_containers_examples/tsconfig.json b/examples/state_containers_examples/tsconfig.json index 6cfb9f9dc2321..442fa08022dc4 100644 --- a/examples/state_containers_examples/tsconfig.json +++ b/examples/state_containers_examples/tsconfig.json @@ -14,6 +14,8 @@ ], "exclude": [], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/examples/ui_action_examples/tsconfig.json b/examples/ui_action_examples/tsconfig.json index 86b35c5e4943f..253fdd9ee6c89 100644 --- a/examples/ui_action_examples/tsconfig.json +++ b/examples/ui_action_examples/tsconfig.json @@ -13,6 +13,7 @@ ], "exclude": [], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/examples/ui_actions_explorer/tsconfig.json b/examples/ui_actions_explorer/tsconfig.json index 782b9cd57fa7b..b4449819b25a6 100644 --- a/examples/ui_actions_explorer/tsconfig.json +++ b/examples/ui_actions_explorer/tsconfig.json @@ -12,6 +12,7 @@ ], "exclude": [], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/package.json b/package.json index 6122c1090671f..5cd0c276ef76c 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,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 && node scripts/register_git_hook", + "kbn:bootstrap": "node scripts/build_ts_refs --project tsconfig.refs.json && node scripts/register_git_hook", "spec_to_console": "node scripts/spec_to_console", "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", "storybook": "node scripts/storybook", diff --git a/src/dev/typescript/build_refs.ts b/src/dev/typescript/build_refs.ts index cbb596c185f8b..de006bd674e87 100644 --- a/src/dev/typescript/build_refs.ts +++ b/src/dev/typescript/build_refs.ts @@ -18,12 +18,18 @@ */ import execa from 'execa'; +import Path from 'path'; import { run, ToolingLog } from '@kbn/dev-utils'; -export async function buildRefs(log: ToolingLog) { +export async function buildAllRefs(log: ToolingLog) { + await buildRefs(log, 'tsconfig.refs.json'); + await buildRefs(log, Path.join('x-pack', 'tsconfig.refs.json')); +} + +async function buildRefs(log: ToolingLog, projectPath: string) { try { - log.info('Building TypeScript projects refs...'); - await execa(require.resolve('typescript/bin/tsc'), ['-b', 'tsconfig.refs.json']); + log.debug(`Building TypeScript projects refs for ${projectPath}...`); + await execa(require.resolve('typescript/bin/tsc'), ['-b', projectPath]); } catch (e) { log.error(e); process.exit(1); @@ -31,7 +37,18 @@ export async function buildRefs(log: ToolingLog) { } export async function runBuildRefs() { - run(async ({ log }) => { - await buildRefs(log); - }); + run( + async ({ log, flags }) => { + await buildRefs(log, flags.project as string); + }, + { + description: 'Build TypeScript projects', + flags: { + string: ['project'], + help: ` +--project Required, path to the tsconfig.refs.file + `, + }, + } + ); } diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 4d1e549e192b6..9891e9fa02c82 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -24,11 +24,11 @@ import { Project } from './project'; export const PROJECTS = [ new Project(resolve(REPO_ROOT, 'tsconfig.json')), - new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')), - new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')), new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }), new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')), new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }), + new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')), + new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')), new Project(resolve(REPO_ROOT, 'x-pack/plugins/security_solution/cypress/tsconfig.json'), { name: 'security_solution/cypress', }), @@ -47,6 +47,12 @@ export const PROJECTS = [ ...glob .sync('packages/*/tsconfig.json', { cwd: REPO_ROOT }) .map((path) => new Project(resolve(REPO_ROOT, path))), + ...glob + .sync('src/plugins/*/tsconfig.json', { cwd: REPO_ROOT }) + .map((path) => new Project(resolve(REPO_ROOT, path))), + ...glob + .sync('x-pack/plugins/*/tsconfig.json', { cwd: REPO_ROOT }) + .map((path) => new Project(resolve(REPO_ROOT, path))), ...glob .sync('examples/*/tsconfig.json', { cwd: REPO_ROOT }) .map((path) => new Project(resolve(REPO_ROOT, path))), diff --git a/src/dev/typescript/run_type_check_cli.ts b/src/dev/typescript/run_type_check_cli.ts index 00968b7259a30..c52b9454c28be 100644 --- a/src/dev/typescript/run_type_check_cli.ts +++ b/src/dev/typescript/run_type_check_cli.ts @@ -24,7 +24,7 @@ import getopts from 'getopts'; import { execInProjects } from './exec_in_projects'; import { filterProjectsByFlag } from './projects'; -import { buildRefs } from './build_refs'; +import { buildAllRefs } from './build_refs'; export async function runTypeCheckCli() { const extraFlags: string[] = []; @@ -80,7 +80,7 @@ export async function runTypeCheckCli() { process.exit(); } - await buildRefs(log); + await buildAllRefs(log); const tscArgs = [ // composite project cannot be used with --noEmit diff --git a/src/plugins/kibana_react/kibana.json b/src/plugins/kibana_react/kibana.json index a507fe457b633..c05490c349917 100644 --- a/src/plugins/kibana_react/kibana.json +++ b/src/plugins/kibana_react/kibana.json @@ -2,5 +2,6 @@ "id": "kibanaReact", "version": "kibana", "ui": true, + "server": false, "requiredBundles": ["kibanaUtils"] } diff --git a/src/plugins/kibana_react/tsconfig.json b/src/plugins/kibana_react/tsconfig.json new file mode 100644 index 0000000000000..52899f868dbfb --- /dev/null +++ b/src/plugins/kibana_react/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "public/**/*", + "../../../typings/**/*" + ], + "references": [ + { "path": "../kibana_utils/tsconfig.json" } + ] +} diff --git a/src/plugins/kibana_utils/kibana.json b/src/plugins/kibana_utils/kibana.json index 7e2127c27548e..3e20b68bca431 100644 --- a/src/plugins/kibana_utils/kibana.json +++ b/src/plugins/kibana_utils/kibana.json @@ -2,6 +2,7 @@ "id": "kibanaUtils", "version": "kibana", "ui": true, + "server": false, "extraPublicDirs": [ "common", "demos/state_containers/todomvc", diff --git a/src/plugins/kibana_utils/tsconfig.json b/src/plugins/kibana_utils/tsconfig.json new file mode 100644 index 0000000000000..bd65e06c78608 --- /dev/null +++ b/src/plugins/kibana_utils/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "demos/**/*", + "public/**/*", + "server/**/*", + "index.ts", + "../../../typings/**/*" + ], + "references": [ + { "path": "../../test_utils/tsconfig.json" }, + { "path": "../../core/tsconfig.json" } + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 6e846690d54d9..2c92367f84823 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -18,6 +18,8 @@ "interpreter_functional/plugins/**/*" ], "references": [ - { "path": "../src/core/tsconfig.json" } + { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/kibana_react/tsconfig.json" } ] } diff --git a/tsconfig.json b/tsconfig.json index 11838627c5319..fb57936248cf6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,9 @@ "exclude": [ "src/**/__fixtures__/**/*", "src/test_utils/**/*", - "src/core/**/*" + "src/core/**/*", + "src/plugins/kibana_utils/**/*", + "src/plugins/kibana_react/**/*" // In the build we actually exclude **/public/**/* from this config so that // we can run the TSC on both this and the .browser version of this config // file, but if we did it during development IDEs would not be able to find @@ -21,6 +23,8 @@ ], "references": [ { "path": "./src/test_utils/tsconfig.json" }, - { "path": "./src/core/tsconfig.json" } + { "path": "./src/core/tsconfig.json" }, + { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/kibana_react/tsconfig.json" } ] } diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 66282687f633b..54bd07e4b134c 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -1,7 +1,9 @@ { "include": [], "references": [ - { "path": "./src/test_utils" }, - { "path": "./src/core" }, + { "path": "./src/test_utils/tsconfig.json" }, + { "path": "./src/core/tsconfig.json" }, + { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json index 9f4f010c20fec..f8c1a6b53dac5 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json +++ b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json @@ -13,6 +13,8 @@ ], "exclude": [], "references": [ - { "path": "../../../src/core/tsconfig.json" } + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, ] } diff --git a/x-pack/package.json b/x-pack/package.json index cd981b78aea63..97d673290abd1 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -6,7 +6,7 @@ "license": "Elastic-License", "scripts": { "kbn": "node ../scripts/kbn", - "kbn:bootstrap": "node plugins/canvas/scripts/storybook --clean", + "kbn:bootstrap": "node ../scripts/build_ts_refs --project tsconfig.refs.json && node plugins/canvas/scripts/storybook --clean", "start": "node ../scripts/kibana --dev", "build": "gulp build", "testonly": "echo 'Deprecated, use `yarn test`' && gulp test", diff --git a/x-pack/plugins/licensing/tsconfig.json b/x-pack/plugins/licensing/tsconfig.json new file mode 100644 index 0000000000000..9b8eb15dc4a9e --- /dev/null +++ b/x-pack/plugins/licensing/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "public/**/*", + "server/**/*", + "common/**/*", + "../../../typings/**/*" + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" } + ] +} diff --git a/x-pack/plugins/transform/tsconfig.json b/x-pack/plugins/transform/tsconfig.json deleted file mode 100644 index 6f83eb665f830..0000000000000 --- a/x-pack/plugins/transform/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.json", -} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 3736d957a55a6..628f2edefb079 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -17,6 +17,9 @@ "../typings/jest.d.ts" ], "references": [ - { "path": "../../src/core/tsconfig.json" } + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../plugins/licensing/tsconfig.json" } ] } diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 7978a89231566..d4722aba4882c 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -11,7 +11,8 @@ "test/**/*", "plugins/security_solution/cypress/**/*", "plugins/apm/e2e/cypress/**/*", - "plugins/apm/scripts/**/*" + "plugins/apm/scripts/**/*", + "plugins/licensing/**/*" ], "compilerOptions": { "outDir": ".", @@ -24,5 +25,10 @@ // overhead is too significant "incremental": false }, - "references": [{ "path": "../src/core/tsconfig.json" }] + "references": [ + { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/kibana_react/tsconfig.json" }, + { "path": "./plugins/licensing/tsconfig.json" } + ] } diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json new file mode 100644 index 0000000000000..0b4c46b893aa8 --- /dev/null +++ b/x-pack/tsconfig.refs.json @@ -0,0 +1,6 @@ +{ + "include": [], + "references": [ + { "path": "./plugins/licensing/tsconfig.json" } + ] +}