-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): match tsconfig include paths properly (#4676)
this commit fixes a bug where a user was unable to use relative paths in the `include` property of their `tsconfig.json` file if `srcDir` was also specified. previously, when `tsconfig.json#include` contained a relative path: ``` "include": [ "./app/javascript" ], ``` and `tsconfig.json#srcDir` included the non-relative version of that path: ``` srcDir: 'app/javascript', ``` then you would receive a very confusing error: ``` [ WARN ] tsconfig.json "include" required 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 "app/javascript" directory listed. For example: "include": ["app/javascript"] ``` closes #4667
- Loading branch information
1 parent
a62498c
commit 664ecb7
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/compiler/sys/typescript/tests/typescript-config.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { hasSrcDirectoryInclude } from '../typescript-config'; | ||
|
||
describe('typescript-config', () => { | ||
describe('hasSrcDirectoryInclude', () => { | ||
it('returns `false` for a non-array argument', () => { | ||
// the intent of this test is to evaluate when a user doesn't provide an array, hence the type assertion | ||
expect(hasSrcDirectoryInclude('src' as unknown as string[], 'src')).toBe(false); | ||
}); | ||
|
||
it('returns `false` for an empty array', () => { | ||
expect(hasSrcDirectoryInclude([], 'src/')).toBe(false); | ||
}); | ||
|
||
it('returns `false` when an entry does not exist in the array', () => { | ||
expect(hasSrcDirectoryInclude(['src'], 'source')).toBe(false); | ||
}); | ||
|
||
it('returns `true` when an entry does exist in the array', () => { | ||
expect(hasSrcDirectoryInclude(['src', 'foo'], 'src')).toBe(true); | ||
}); | ||
|
||
it('returns `true` for globs', () => { | ||
expect(hasSrcDirectoryInclude(['src/**/*.ts', 'foo/'], 'src/**/*.ts')).toBe(true); | ||
}); | ||
|
||
it.each([ | ||
[['src'], './src'], | ||
[['./src'], 'src'], | ||
[['../src'], '../src'], | ||
[['*'], './*'], | ||
])('returns `true` for relative paths', (includedPaths, srcDir) => { | ||
expect(hasSrcDirectoryInclude(includedPaths, srcDir)).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters