-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds glob-style pattern matching for file specifications using new "include" property in tsconfig.json #3232
Conversation
Edit: This is now supported. You should be able to do the following:
|
Looks interesting. The question here is whether the delta between the simple exclude list and this PR is worth another 500 lines of non-trivial code (plus we'd have to add tests for all the wildcard features). I do think the vast majority of use cases are covered with just a simple list. Also, the simple list solution has the advantage that it never even enumerates excluded subfolders whereas this code appears to enumerate them and the subsequently eliminates all the files. This could be significant from a performance perspective. And obviously it's fixable with some extra work. |
In the simple list case, if there are no wildcards in the file list, no directories are enumerated. I agree that a small change can avoid enumerating excluded directories in the case where there is a wildcard in the list, by checking the base path against the exclusion list prior to descending into a directory in both |
I've made a few changes, for your consideration:
I've also added a number of tests to cover this feature. |
"include"
property in tsconfig.json
"include"
property in tsconfig.json
Is it safe to assume that the pattern matching is relative to the directory the I assume the pattern matching is on the full (relative) path? |
* @param isLiteralFile A value indicating whether the file to be added is | ||
* a literal file, or the result of matching a file specification. | ||
*/ | ||
function includeFile(file: string, isLiteralFile: boolean): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add the output array as a function parameter to decouple this function from expandFiles
instead using a closure to access output
. This increases readability, decoupling, testing and performance of the function. This same comment probably applies to other functions defined in expandFiles
too.
Is this still happening seems to have stalled |
@rbuckton got busy with other changes. i would say it is open for others to pick it up if anyone is interested. |
Would love to see this, or something like the I know the community is yearning for glob support! |
+1 |
+1 million, this will make things much easier for some Angular/RxJS users who don't simply have the hello world example file structure :) |
+1 as well. Can hobble along without, but this would make things a lot easier for me. Started using Aurelia which includes it's own d.ts files. They track versions in the file path for the definition file. So I can see each time I update, i'll have to manually update all references into the framework so typescript can find the definition files. With this in, then I can path match to ignore the version part of the path so typescript will always find the updated definition file. |
I spent over 4 hours last night trying to get this to run on top of the latest code. First with a rebase, which had about 8 or 9 conflicted files, where I was able to resolve all but one of those (commandLineParser.ts), which was just too confusing for me. Then I aborted that, and tried to reconstruct the branch manually, but I quickly ran into issues with the test system (which is what I tried to start with). So, I gave up. I just don't know enough about the code and the testing system. :( @rbuckton, do you think that you will ever find time to finish this, or at least rebase it, or will it have to be picked up by someone else? @chrsmrtn-, one option is to use |
Really need this +million |
It's crazy that this is pretty much being ignored, editors are adding file globs into them and people are creating modules just to do this task clearly the community want this feature. As a work around I currently have a watch with https://github.com/wjohnsto/tsconfig-glob and tsc, you could also go down the route of grunt-ts. |
@scottwio: Actually, I'm about to close this PR and open a new one with an updated implementation. |
@rbuckton in that case your my hero |
Closed in favor of #5980. |
Adds support for expanding glob-like patterns in "include" and "exclude" properties of tsconfig.json. The following patterns are supported:
*
- Matches zero or more characters, excluding directory separators.?
- Matches any one character, excluding directory separators.[abc]
- Matches any one character in the set{ "a", "b", "c" }
.[a-z]
- Matches any one character in between"a"
and"z"
.[!abc]
- Matches any one character not in the set{ "a", "b", "c" }
.**/
- Recursively matches any subdirectory.At this time, character escape sequences are not supported, as there is no standard cross-platform convention. The standard escape sequence in a Unix shell is prefixed with
\
, which is reserved as a directory separator on Windows, and is normalized to/
by TypeScript.This does not use the glob module, as TypeScript runs in more host environments than just NodeJS, and this would need interoperate with the language service host.
"files"
list are always added to the list of files."exclude"
list only applies to files matched via"include"
."files"
nor"include"
are present,"include"
defaults to"**/*.ts"
. This preserves the existing behavior.