Skip to content

Commit

Permalink
fix(): add warning for missing include of the srcDir
Browse files Browse the repository at this point in the history
fixes #2380
  • Loading branch information
manucorporat committed May 6, 2020
1 parent 180e890 commit c6b954c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/sys/typescript/typescript-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ export const validateTsConfig = async (ts: typeof tsTypes, config: d.Config, sys
});
} else {
if (results.raw) {
if (!hasSrcDirectoryInclude(results.raw.include)) {
const srcDir = relative(config.rootDir, config.srcDir);
if (!hasSrcDirectoryInclude(results.raw.include, srcDir)) {
const warn = buildWarn(tsconfig.diagnostics);
warn.header = `tsconfig.json "include" required`;
warn.messageText = `In order for TypeScript to improve watch performance, it's recommended the "tsconfig.json" file should have the "include" property, with at least the app's "src" directory listed. For example: "include": ["src"]`;
warn.messageText = `In order for TypeScript to improve watch performance, it's recommended the "tsconfig.json" file should have the "include" property, with at least the app's "${srcDir}" directory listed. For example: "include": ["${srcDir}"]`;
}

if (hasStencilConfigInclude(results.raw.include)) {
Expand Down Expand Up @@ -134,6 +135,6 @@ const createDefaultTsConfig = (config: d.Config) =>
2,
);

const hasSrcDirectoryInclude = (includeProp: string[]) => Array.isArray(includeProp) && includeProp.length > 0;
const hasSrcDirectoryInclude = (includeProp: string[], src: string) => Array.isArray(includeProp) && includeProp.includes(src);

const hasStencilConfigInclude = (includeProp: string[]) => Array.isArray(includeProp) && includeProp.includes('stencil.config.ts');

0 comments on commit c6b954c

Please sign in to comment.