Add tests, comments, and min.js exclusion

This commit is contained in:
Ryan Cavanaugh
2017-04-10 16:00:15 -07:00
parent 2ca90b7eb6
commit 2b3c2b3448
2 changed files with 63 additions and 2 deletions

View File

@@ -61,6 +61,24 @@ namespace ts.server {
"smart": IndentStyle.Smart
});
/**
* How to understand this block:
* * The 'match' property is a regexp that matches a filename.
* * If 'match' is successful, then:
* * All files from 'exclude' are removed from the project. See below.
* * All 'types' are included in ATA
* * What the heck is 'exclude' ?
* * An array of an array of strings and numbers
* * Each array is:
* * An array of strings and numbers
* * The strings are literals
* * The numbers refer to capture group indices from the 'match' regexp
* * Remember that '1' is the first group
* * These are concatenated together to form a new regexp
* * Filenames matching these regexps are excluded from the project
* This default value is tested in tsserverProjectSystem.ts; add tests there
* if you are changing this so that you can be sure your regexp works!
*/
const defaultTypeSafeList: SafeList = {
"jquery": {
// jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js")
@@ -84,6 +102,11 @@ namespace ts.server {
"match": /^(.*\/office\/1)\/excel-\d+\.debug\.js$/i, // Office NuGet package is installed under a "1/office" folder
"exclude": [["^", 1, "/.*"]], // Exclude that whole folder if the file indicated above is found in it
"types": ["office"] // @types package to fetch instead
},
"Minified files": {
// e.g. /whatever/blah.min.js
"match": /^(.+\.min\.js)$/i,
"exclude": [["^", 1, "$"]]
}
};
@@ -1507,7 +1530,7 @@ namespace ts.server {
// Copy back this field into the project if needed
if (types.length > 0) {
proj.typeAcquisition = proj.typeAcquisition || { };
proj.typeAcquisition = proj.typeAcquisition || {};
proj.typeAcquisition.include = types;
}
}