diff --git a/src/dev/file.ts b/src/dev/file.ts index b4283de3dbe4..5dc66016e1e5 100644 --- a/src/dev/file.ts +++ b/src/dev/file.ts @@ -48,6 +48,10 @@ export class File { return this.ext === '.ts' || this.ext === '.tsx'; } + public isTypescriptAmbient() { + return this.path.endsWith('.d.ts'); + } + public isSass() { return this.ext === '.sass' || this.ext === '.scss'; } diff --git a/src/dev/typescript/get_ts_project_for_absolute_path.ts b/src/dev/typescript/get_ts_project_for_absolute_path.ts index 409d18bed6f5..843743fd7a3b 100644 --- a/src/dev/typescript/get_ts_project_for_absolute_path.ts +++ b/src/dev/typescript/get_ts_project_for_absolute_path.ts @@ -17,9 +17,10 @@ * under the License. */ -import { relative } from 'path'; +import { relative, resolve } from 'path'; import { REPO_ROOT } from '../constants'; +import { File } from '../file'; import { PROJECTS } from './projects'; /** @@ -33,6 +34,7 @@ import { PROJECTS } from './projects'; */ export function getTsProjectForAbsolutePath(path: string) { const relPath = relative(REPO_ROOT, path); + const file = new File(resolve(REPO_ROOT, path)); const projects = PROJECTS.filter(p => p.isAbsolutePathSelected(path)); if (!projects.length) { @@ -41,7 +43,7 @@ export function getTsProjectForAbsolutePath(path: string) { ); } - if (projects.length !== 1) { + if (projects.length !== 1 && !file.isTypescriptAmbient()) { const configPaths = projects.map(p => `"${relative(REPO_ROOT, p.tsConfigPath)}"`); const pathsMsg = `${configPaths.slice(0, -1).join(', ')} or ${ diff --git a/src/dev/typescript/run_check_ts_projects_cli.ts b/src/dev/typescript/run_check_ts_projects_cli.ts index d9c1259882c5..d4a4b5dee5fa 100644 --- a/src/dev/typescript/run_check_ts_projects_cli.ts +++ b/src/dev/typescript/run_check_ts_projects_cli.ts @@ -55,7 +55,7 @@ export async function runCheckTsProjectsCli() { if (projects.length === 0) { isNotInTsProject.push(file); } - if (projects.length > 1) { + if (projects.length > 1 && !file.isTypescriptAmbient()) { isInMultipleTsProjects.push(file); } }