-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 files in tsconfig.json #5980
Conversation
// wildcard paths. | ||
const literalFiles = createFileMap<Path>(keyMapper); | ||
|
||
// Wildcard paths (provided via the "includes" array in tscofnig.json) are stored in a |
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.
tsconfig.json
@@ -161,7 +161,8 @@ var harnessSources = harnessCoreSources.concat([ | |||
"reuseProgramStructure.ts", | |||
"cachingInServerLSHost.ts", | |||
"moduleResolution.ts", | |||
"tsconfigParsing.ts" | |||
"tsconfigParsing.ts", | |||
"expandFiles.ts" |
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.
Add this file to the tsconfig.json files in src\**\
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.
There is no tsconfig.json in either src/harness or tests/cases/unittests
@paulvanbrenk, @DanielRosenwasser, @vladima, @ahejlsberg Any comments on this approach? |
@@ -584,4 +581,233 @@ namespace ts { | |||
|
|||
return { options, errors }; | |||
} | |||
|
|||
const invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; |
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.
Can you add comments to all these regular expressions.. they are impossible to parse.
directories: string[]; | ||
} | ||
|
||
export function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[] { |
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.
doesn't this make more sense in sys.ts ?
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.
Most of our other path logic exists in core.ts.
Need this so badly |
Odd. All I did was merge from master. I'll check into this shortly. |
What still needs to be done before this can be merged? (other than resolving the conflicts) |
const keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; | ||
|
||
// Literal file names (provided via the "files" array in tsconfig.json) are stored in a | ||
// file map with a possibly case insensitive key. We use this map later when when including |
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.
We use this map later when including
@rbuckton Is there any way that TypeScript could expose the globbing logic so that other libraries could easily get the list of files, without having to re-implement all of the rules? I was trying to implement the include/exclude stuff using globby, but it seems that an exclude entry like Edit: The use case is getting a list of files for Edit 2: Actually getting a list of files isn't really useful, as it won't match files created later. 😞 |
Curious what the status on this one is |
Why isn't TypeScript using a community-vetted library like minimatch that WILL run in all environments? Implementing glob and not doing it fully is not as helpful as supporting the standard glob syntax used throughout the JS ecosystem. |
The typescript compiler runs in other environments other than node, e.g. web (monaco web editor), VSCode, (uses its own require implementation), VS (chakra), etc.. so dependencies can be tricky. We are working on getting this done soon. so please bear with us for a bit longer. |
Exciting 😀 |
Supersedes #3232.
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.**/
- Recursively matches any subdirectory.*
or.*
, only supported extensions are considered (e.g. ".ts", ".tsx", and ".d.ts" by default, and also ".js" and ".jsx" ifallowJs
istrue
).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. Character ranges are also not included at this time.This does not use the glob module, as TypeScript runs in more host environments than just NodeJS, and this would need to interoperate with the language service host.
Notes:
"files"
list are always added to the list of files."exclude"
list only applies to files matched via"include"
. If the leading directory of a path is excluded, it will not be traversed. You cannot re-include an excluded file, other than through providing it as a literal path in the"files"
list."files"
nor"include"
are present,"include"
defaults to"**/*"
but only includes files with supported extensions. This preserves the existing behavior.