[CI] Only emit .d.ts when running typecheck (#209259)

## Summary
Stop emitting any `.js` files during typechecking. We only depend on the
declarations, not the emitted, compiled javascript files.

An added benefit, is making some bad import errors more obvious.  
We'll no longer try to build javascript files in place if a poor
import/require is made, rather the error of importing outside projects
(in the forest of a bunch of errors possibly) will be visible in the
typescript logs:
```
# instead of:
proc [tsc] error TS5055: Cannot write file '/opt/buildkite-agent/builds/bk-agent-prod-gcp-1741789017236110254/elastic/kibana-pull-request/kibana/src/platform/packages/shared/kbn-babel-register/cache/no_cache_cache.js' because it would overwrite input file.

# we'll see:
... several others like this
 proc [tsc] src/platform/packages/shared/kbn-grok-ui/scripts/generate_patterns.js:10:9 - error TS6307: File '/Users/alex/Git/elastic-kibana/src/setup_node_env/index.js' is not listed within the file list of project '/Users/alex/Git/elastic-kibana/src/platform/packages/shared/kbn-grok-ui/tsconfig.type_check.json'. Projects must list all files or use an 'include' pattern.
 proc [tsc] 
 proc [tsc] 10 require('../../../../../setup_node_env');
... several others like this
```
This commit is contained in:
Alex Szabo 2025-03-18 11:48:14 +01:00 committed by GitHub
parent 53970f276c
commit 702c9c49dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -9,7 +9,7 @@
import { getCodeOwnersForFile, getPathsWithOwnersReversed } from './code_owners.ts';
interface DependencyByOwnerEntry<T = string[]> {
export interface DependencyByOwnerEntry<T = string[]> {
modules: T;
deps: T;
teams: T;

View file

@ -47,6 +47,8 @@ async function createTypeCheckConfigs(log: SomeDevLog, projects: TsProject[]) {
...config.compilerOptions,
composite: true,
rootDir: '.',
noEmit: false,
emitDeclarationOnly: true,
paths: project.repoRel === 'tsconfig.base.json' ? config.compilerOptions?.paths : undefined,
},
kbn_references: undefined,