diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 56d132fc925b4..507997c346de3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -24,14 +24,14 @@ namespace ts { * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. */ export function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray { - if (elements) { + if (!elements || elements === emptyArray) { + elements = []; + } + else { if (isNodeArray(elements)) { return elements; } } - else { - elements = []; - } const array = >elements; array.pos = -1; diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index 278127e81cea4..47116cd5b0129 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -2333,9 +2333,9 @@ declare module "fs" { verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.NonRecursiveWatchDirectory); }); - // it("uses non recursive dynamic polling when renaming file in subfolder", () => { - // verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling); - // }); + it("uses non recursive dynamic polling when renaming file in subfolder", () => { + verifyRenamingFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling); + }); }); }); } diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index dd2f123826018..9c8744f179e41 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -88,7 +88,7 @@ interface Array {}` } interface Folder extends FSEntry { - entries: FSEntry[]; + entries: SortedArray; } interface SymLink extends FSEntry { @@ -504,7 +504,7 @@ interface Array {}` } private addFileOrFolderInFolder(folder: Folder, fileOrDirectory: File | Folder | SymLink, ignoreWatch?: boolean) { - folder.entries.push(fileOrDirectory); + insertSorted(folder.entries, fileOrDirectory, (a, b) => compareStringsCaseSensitive(getBaseFileName(a.path), getBaseFileName(b.path))); folder.modifiedTime = new Date(); this.fs.set(fileOrDirectory.path, fileOrDirectory); @@ -606,7 +606,7 @@ interface Array {}` private toFolder(path: string): Folder { const folder = this.toFsEntry(path) as Folder; - folder.entries = []; + folder.entries = [] as SortedArray; return folder; }