Exclude ambient type definitions from checkTsProjects (#33737)

This commit is contained in:
Josh Dover 2019-03-22 16:48:53 -05:00 committed by GitHub
parent 74d3301b08
commit 53ab06898b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -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';
}

View file

@ -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 ${

View file

@ -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);
}
}