Skip to content

Commit 17b10dc

Browse files
authored
Merge pull request #21243 from Microsoft/watchOptions
Different watchFile and watchDirectory options through environment variable
2 parents a81f264 + 8378f69 commit 17b10dc

14 files changed

+1292
-568
lines changed

src/compiler/commandLineParser.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ namespace ts {
20292029
export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray<JsFileExtensionInfo> = []): ExpandResult {
20302030
basePath = normalizePath(basePath);
20312031

2032-
const keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper;
2032+
const keyMapper = host.useCaseSensitiveFileNames ? identity : toLowerCase;
20332033

20342034
// Literal file names (provided via the "files" array in tsconfig.json) are stored in a
20352035
// file map with a possibly case insensitive key. We use this map later when when including
@@ -2233,24 +2233,6 @@ namespace ts {
22332233
}
22342234
}
22352235

2236-
/**
2237-
* Gets a case sensitive key.
2238-
*
2239-
* @param key The original key.
2240-
*/
2241-
function caseSensitiveKeyMapper(key: string) {
2242-
return key;
2243-
}
2244-
2245-
/**
2246-
* Gets a case insensitive key.
2247-
*
2248-
* @param key The original key.
2249-
*/
2250-
function caseInsensitiveKeyMapper(key: string) {
2251-
return key.toLowerCase();
2252-
}
2253-
22542236
/**
22552237
* Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed.
22562238
* Also converts enum values back to strings.

src/compiler/core.ts

+36
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ namespace ts {
2525
/* @internal */
2626
namespace ts {
2727
export const emptyArray: never[] = [] as never[];
28+
export function closeFileWatcher(watcher: FileWatcher) {
29+
watcher.close();
30+
}
31+
2832
/** Create a MapLike with good performance. */
2933
function createDictionaryObject<T>(): MapLike<T> {
3034
const map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword
@@ -3142,4 +3146,36 @@ namespace ts {
31423146
export function singleElementArray<T>(t: T | undefined): T[] | undefined {
31433147
return t === undefined ? undefined : [t];
31443148
}
3149+
3150+
export function enumerateInsertsAndDeletes<T, U>(newItems: ReadonlyArray<T>, oldItems: ReadonlyArray<U>, comparer: (a: T, b: U) => Comparison, inserted: (newItem: T) => void, deleted: (oldItem: U) => void, unchanged?: (oldItem: U, newItem: T) => void) {
3151+
unchanged = unchanged || noop;
3152+
let newIndex = 0;
3153+
let oldIndex = 0;
3154+
const newLen = newItems.length;
3155+
const oldLen = oldItems.length;
3156+
while (newIndex < newLen && oldIndex < oldLen) {
3157+
const newItem = newItems[newIndex];
3158+
const oldItem = oldItems[oldIndex];
3159+
const compareResult = comparer(newItem, oldItem);
3160+
if (compareResult === Comparison.LessThan) {
3161+
inserted(newItem);
3162+
newIndex++;
3163+
}
3164+
else if (compareResult === Comparison.GreaterThan) {
3165+
deleted(oldItem);
3166+
oldIndex++;
3167+
}
3168+
else {
3169+
unchanged(oldItem, newItem);
3170+
newIndex++;
3171+
oldIndex++;
3172+
}
3173+
}
3174+
while (newIndex < newLen) {
3175+
inserted(newItems[newIndex++]);
3176+
}
3177+
while (oldIndex < oldLen) {
3178+
deleted(oldItems[oldIndex++]);
3179+
}
3180+
}
31453181
}

0 commit comments

Comments
 (0)