Skip to content

Commit 9a78868

Browse files
committed
Post conversion fixes
1 parent 809349d commit 9a78868

File tree

12 files changed

+54
-47
lines changed

12 files changed

+54
-47
lines changed

Gulpfile.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const { buildProject, cleanProject, watchProject } = require("./scripts/build/pr
1818
const cmdLineOptions = require("./scripts/build/options");
1919

2020
const copyright = "CopyrightNotice.txt";
21+
const testRoot = "built/local/testRunner/Harness.js"
2122
const cleanTasks = [];
2223

2324
const buildScripts = () => buildProject("scripts");
@@ -442,7 +443,7 @@ preTest.displayName = "preTest";
442443

443444
const postTest = (done) => cmdLineOptions.lint ? lint(done) : done();
444445

445-
const runTests = () => runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
446+
const runTests = () => runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
446447
task("runtests", series(preBuild, preTest, runTests, postTest));
447448
task("runtests").description = "Runs the tests using the built run.js file.";
448449
task("runtests").flags = {
@@ -462,7 +463,7 @@ task("runtests").flags = {
462463
" --shardId": "1-based ID of this shard (default: 1)",
463464
};
464465

465-
const runTestsParallel = () => runConsoleTests("built/local/run.js", "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
466+
const runTestsParallel = () => runConsoleTests(testRoot, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
466467
task("runtests-parallel", series(preBuild, preTest, runTestsParallel, postTest));
467468
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
468469
task("runtests-parallel").flags = {
@@ -611,10 +612,10 @@ task("publish-nightly").description = "Runs `npm publish --tag next` to create a
611612
// write some kind of trigger file that indicates build completion that we could listen for instead.
612613
const watchRuntests = () => watch(["built/local/*.js", "tests/cases/**/*.ts", "tests/cases/**/tsconfig.json"], { delay: 5000 }, async () => {
613614
if (cmdLineOptions.tests || cmdLineOptions.failed) {
614-
await runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
615+
await runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
615616
}
616617
else {
617-
await runConsoleTests("built/local/run.js", "min", /*runInParallel*/ true, /*watchMode*/ true);
618+
await runConsoleTests(testRoot, "min", /*runInParallel*/ true, /*watchMode*/ true);
618619
}
619620
});
620621
task("watch", series(preBuild, preTest, parallel(watchLib, watchDiagnostics, watchServices, watchLssl, watchTests, watchRuntests)));

src/harness/fourslashImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { TestCaseParser, Compiler, isDefaultLibraryFile, IO, getConfigNameFromFileName, Baseline, virtualFileSystemRoot } from "./Harness";
32
import { FileSet, File, FileSystem } from "./vfs";
43
import { ESMap, MultiMap, TextRange, ImplementationLocation, CompilerOptions, ScriptTarget, HostCancellationToken, Debug, OperationCanceledException, DiagnosticMessage, IScriptSnapshot, ScriptSnapshot, LanguageService, FormatCodeSettings, SymbolDisplayPart, forEach, parseConfigFileTextToJson, normalizePath, getDirectoryPath, convertCompilerOptionsFromJson, extend, ParsedCommandLine, parseJsonText, parseJsonSourceFileConfigFileContent, getNormalizedAbsolutePath, FileReference, flatten, getSupportedExtensions, contains, isDeclarationFileName, containsPath, some, testFormatSettings, getAllKeys, isString, forEachEntry, LineAndCharacter, normalizeSlashes, emptyOptions, Diagnostic, emptyArray, flatMap, isAnySupportedFileExtension, getBaseFileName, flattenDiagnosticMessageText, SourceFile, getLineAndCharacterOfPosition, forEachKey, getAllowJSCompilerOption, resolutionExtensionIsTSOrJson, extensionFromPath, DiagnosticCategory, createTextSpanFromRange, isNumber, textSpansEqual, DefinitionInfo, DefinitionInfoAndBoundSpan, isArray, hasProperty, zipWith, comparePaths, Comparison, deduplicate, equateValues, textSpanEnd, sys, OutputFile, InlayHintsOptions, InlayHint, CompletionEntry, Completions, displayPartsToString, Program, TypeChecker, Node, getTouchingPropertyName, Symbol, SymbolFlags, MapLike, getEntries, ReferenceEntry, map, find, ReferencedSymbol, group, sort, textSpanContainsPosition, UserPreferences, GetCompletionsAtPositionOptions, CompletionInfo, CompletionEntryData, CompletionEntryDetails, realizeDiagnostics, RealizedDiagnostic, JSDocTagInfo, RenameLocation, compareStringsCaseSensitive, textSpanIntersectsWithPosition, SignatureHelpTriggerReason, SignatureHelpParameter, RenameInfoOptions, CharacterCodes, computeLineStarts, computeLineAndCharacterOfPosition, padLeft, repeatString, getPreEmitDiagnostics, DiagnosticMessageChain, filter, endsWith, arrayFrom, SelectionRange, isLineBreak, isWhiteSpaceLike, findLastIndex, concatenate, Extension, SignatureHelpItems, createLanguageServiceSourceFile, TextChange, clone, FormatCodeOptions, toEditorSettings, documentSpansEqual, arrayIsEqualTo, createMultiMap, IndentStyle, classifier, ClassifiedSpan, ClassifiedSpan2020, SemanticClassificationFormat, createTextSpan, OutliningSpan, first, mapDefined, formatStringFromArgs, FileTextChanges, textChanges, getOwnKeys, CodeFixAction, equalOwnProperties, createTextRangeFromSpan, textRangeContainsPositionInclusive, firstOrUndefined, codefix, Diagnostics, TextInsertion, DocCommentTemplateOptions, JsxClosingTagInfo, NavigateToItem, ScriptElementKind, combinePaths, length, RefactorTriggerReason, firstDefined, CallHierarchyItem, mapOneOrMany, getPathUpdater, createGetCanonicalFileName, ApplicableRefactorInfo, transpileModule, changeExtension, isRootedDiskPath, append, regExpEscape } from "./ts";
@@ -10,7 +9,8 @@ import { memoize, assertInvariants, assertDiagnosticsEquals, assertStructuralEqu
109
import { SessionClient, protocol } from "./ts.server";
1110
import * as FourSlashInterface from "./FourSlashInterface";
1211
import * as ts from "./ts";
13-
import ArrayOrSingle = FourSlashInterface.ArrayOrSingle;
12+
13+
type ArrayOrSingle<T> = FourSlashInterface.ArrayOrSingle<T>;
1414

1515
export const enum FourSlashTestType {
1616
Native,

src/harness/harnessIO.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { RunnerBase, TypeWriterWalker, TypeWriterResult } from "./Harness";
2-
import { FileSystemEntries, sys, compareStringsCaseSensitive, compareStringsCaseInsensitive, combinePaths, ScriptTarget, createSourceFile, ESMap, SourceFile, getEntries, CompilerOptions, getEmitScriptTarget, CommandLineOption, Diagnostic, parseListTypeOption, parseCustomTypeOption, CommandLineOptionOfCustomType, cloneCompilerOptions, NewLineKind, map, getNormalizedAbsolutePath, fileExtensionIs, Extension, forEach, getAllowJSCompilerOption, removeFileExtension, getDeclarationEmitExtensionForPath, formatDiagnosticsWithColorAndContext, formatDiagnostics, getErrorSummaryText, getErrorCountForSummary, sort, compareDiagnostics, createGetCanonicalFileName, flattenDiagnosticMessageText, diagnosticCategoryName, formatLocation, identity, DiagnosticWithLocation, comparePaths, Comparison, computeLineStarts, TextSpan, textSpanEnd, countWhere, Program, endsWith, flatMap, getAreDeclarationMapsEnabled, contains, convertToBase64, getBaseFileName, CharacterCodes, ScriptKind, length, normalizeSlashes, toPath, startsWith, findIndex, arrayFrom, orderedRemoveItemAt, ReadonlyESMap, optionDeclarations, equateStringsCaseInsensitive, hasProperty, ParsedCommandLine, ParseConfigHost, parseJsonText, normalizePath, getDirectoryPath, parseJsonSourceFileConfigFileContent, ForegroundColorEscapeSequences, find } from "./ts";
2+
import { FileSystemEntries, sys, compareStringsCaseSensitive, compareStringsCaseInsensitive, combinePaths, ScriptTarget, createSourceFile, Map, ESMap, SourceFile, getEntries, CompilerOptions, getEmitScriptTarget, CommandLineOption, Diagnostic, parseListTypeOption, parseCustomTypeOption, CommandLineOptionOfCustomType, cloneCompilerOptions, NewLineKind, map, getNormalizedAbsolutePath, fileExtensionIs, Extension, forEach, getAllowJSCompilerOption, removeFileExtension, getDeclarationEmitExtensionForPath, formatDiagnosticsWithColorAndContext, formatDiagnostics, getErrorSummaryText, getErrorCountForSummary, sort, compareDiagnostics, createGetCanonicalFileName, flattenDiagnosticMessageText, diagnosticCategoryName, formatLocation, identity, DiagnosticWithLocation, comparePaths, Comparison, computeLineStarts, TextSpan, textSpanEnd, countWhere, Program, endsWith, flatMap, getAreDeclarationMapsEnabled, contains, convertToBase64, getBaseFileName, CharacterCodes, ScriptKind, length, normalizeSlashes, toPath, startsWith, findIndex, arrayFrom, orderedRemoveItemAt, ReadonlyESMap, optionDeclarations, equateStringsCaseInsensitive, hasProperty, ParsedCommandLine, ParseConfigHost, parseJsonText, normalizePath, getDirectoryPath, parseJsonSourceFileConfigFileContent, ForegroundColorEscapeSequences, find } from "./ts";
33
import { findUpRoot, assertInvariants, removeByteOrderMark, removeTestPathPrefixes, canonicalizeForHarness, splitContentByNewlines, encodeString } from "./Utils";
44
import { combine, dirname, isDeclaration, isJson, isTypeScript, isJavaScript, addTrailingSeparator } from "./vpath";
55
import { FileSet, srcFolder, builtFolder, testLibFolder, createFromFileSystem, Symlink } from "./vfs";
66
import { CompilationResult } from "./compiler";
77
import { TextDocument } from "./documents";
88
import { CompilerHost } from "./fakes";
9-
import * as ts from "./ts";
109
import * as compiler from "./compiler";
10+
1111
export interface IO {
1212
newLine(): string;
1313
getCurrentDirectory(): string;
@@ -264,7 +264,7 @@ export namespace Compiler {
264264
}
265265

266266
if (!libFileNameSourceFileMap) {
267-
libFileNameSourceFileMap = new ts.Map(getEntries({
267+
libFileNameSourceFileMap = new Map(getEntries({
268268
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts")!, /*languageVersion*/ ScriptTarget.Latest)
269269
}));
270270
}
@@ -307,7 +307,7 @@ export namespace Compiler {
307307
noTypesAndSymbols?: boolean;
308308
}
309309

310-
// Additional options not already in ts.optionDeclarations
310+
// Additional options not already in optionDeclarations
311311
const harnessOptionDeclarations: CommandLineOption[] = [
312312
{ name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: "false" },
313313
{ name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: "false" },
@@ -329,9 +329,9 @@ export namespace Compiler {
329329
let optionsIndex: ESMap<string, CommandLineOption>;
330330
function getCommandLineOption(name: string): CommandLineOption | undefined {
331331
if (!optionsIndex) {
332-
optionsIndex = new ts.Map<string, CommandLineOption>();
333-
const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
334-
for (const option of optionDeclarations) {
332+
optionsIndex = new Map<string, CommandLineOption>();
333+
const optionDecls = harnessOptionDeclarations.concat(optionDeclarations);
334+
for (const option of optionDecls) {
335335
optionsIndex.set(option.name.toLowerCase(), option);
336336
}
337337
}
@@ -605,7 +605,7 @@ export namespace Compiler {
605605
errorsReported = 0;
606606

607607
// 'merge' the lines of each input file with any errors associated with it
608-
const dupeCase = new ts.Map<string, number>();
608+
const dupeCase = new Map<string, number>();
609609
for (const inputFile of inputFiles.filter(f => f.content !== undefined)) {
610610
// Filter down to the errors in the file
611611
const fileErrors = diagnostics.filter((e): e is DiagnosticWithLocation => {
@@ -790,7 +790,7 @@ export namespace Compiler {
790790
if (skipBaseline) {
791791
return;
792792
}
793-
const dupeCase = new ts.Map<string, number>();
793+
const dupeCase = new Map<string, number>();
794794

795795
for (const file of allFiles) {
796796
const { unitName } = file;
@@ -963,7 +963,7 @@ export namespace Compiler {
963963
// Collect, test, and sort the fileNames
964964
const files = Array.from(outputFiles);
965965
files.slice().sort((a, b) => compareStringsCaseSensitive(cleanName(a.file), cleanName(b.file)));
966-
const dupeCase = new ts.Map<string, number>();
966+
const dupeCase = new Map<string, number>();
967967
// Yield them
968968
for (const outputFile of files) {
969969
yield [checkDuplicatedFileName(outputFile.file, dupeCase), "/*====== " + outputFile.file + " ======*/\r\n" + removeByteOrderMark(outputFile.text)];
@@ -1099,7 +1099,7 @@ function getVaryByStarSettingValues(varyBy: string): ReadonlyESMap<string, strin
10991099
return option.type;
11001100
}
11011101
if (option.type === "boolean") {
1102-
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new ts.Map(getEntries({
1102+
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new Map(getEntries({
11031103
true: 1,
11041104
false: 0
11051105
})));
@@ -1449,7 +1449,7 @@ export namespace Baseline {
14491449
string
14501450
]> | null, opts?: BaselineOptions, referencedExtensions?: string[]): void {
14511451
const gen = generateContent();
1452-
const writtenFiles = new ts.Map<string, true>();
1452+
const writtenFiles = new Map<string, true>();
14531453
const errors: Error[] = [];
14541454

14551455
// eslint-disable-next-line no-null/no-null

src/harness/virtualFileSystemWithWatch.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Path, combinePaths, getDirectoryPath, ESMap, patchWriteFileEnsuringDirectory, isString, SortedArray, isArray, MultiMap, FileWatcher, forEach, arrayFrom, ReadonlyESMap, arrayToMap, isNumber, identity, PollingInterval, WatchOptions, FileWatcherCallback, FsWatchCallback, FormatDiagnosticsHost, ModuleResolutionHost, createMultiMap, RequireResult, WatchFileKind, HostWatchFile, HostWatchDirectory, createGetCanonicalFileName, toPath, createSystemWatchFunctions, createSingleFileWatcherPerName, getNormalizedAbsolutePath, directorySeparator, Debug, clone, returnFalse, FileWatcherEventKind, getBaseFileName, insertSorted, compareStringsCaseSensitive, filterMutate, FileSystemEntryKind, createFileWatcherCallback, getRelativePathToDirectoryOrUrl, mapDefined, matchFiles, generateDjb2Hash, sys, clear, WatchDirectoryKind, PollingWatchKind } from "./ts";
1+
import { Path, combinePaths, getDirectoryPath, Set, Map, ESMap, patchWriteFileEnsuringDirectory, isString, SortedArray, isArray, MultiMap, FileWatcher, forEach, arrayFrom, ReadonlyESMap, arrayToMap, isNumber, identity, PollingInterval, WatchOptions, FileWatcherCallback, FsWatchCallback, FormatDiagnosticsHost, ModuleResolutionHost, createMultiMap, RequireResult, WatchFileKind, HostWatchFile, HostWatchDirectory, createGetCanonicalFileName, toPath, createSystemWatchFunctions, createSingleFileWatcherPerName, getNormalizedAbsolutePath, directorySeparator, Debug, clone, returnFalse, FileWatcherEventKind, getBaseFileName, insertSorted, compareStringsCaseSensitive, filterMutate, FileSystemEntryKind, createFileWatcherCallback, getRelativePathToDirectoryOrUrl, mapDefined, matchFiles, generateDjb2Hash, sys, clear, WatchDirectoryKind, PollingWatchKind } from "./ts";
22
import { ServerHost } from "./ts.server";
33
import { IO } from "./Harness";
4-
import * as ts from "./ts";
4+
55
export const libFile: File = {
66
path: "/a/lib/lib.d.ts",
77
content: `/// <reference no-default-lib="true"/>
@@ -136,7 +136,7 @@ export function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly s
136136
}
137137
const notInActual: string[] = [];
138138
const duplicates: string[] = [];
139-
const seen = new ts.Map<string, true>();
139+
const seen = new Map<string, true>();
140140
forEach(expectedKeys, expectedKey => {
141141
if (seen.has(expectedKey)) {
142142
duplicates.push(expectedKey);
@@ -237,8 +237,8 @@ export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDi
237237
}
238238

239239
export function checkOutputContains(host: TestServerHost, expected: readonly string[]) {
240-
const mapExpected = new ts.Set(expected);
241-
const mapSeen = new ts.Set<string>();
240+
const mapExpected = new Set(expected);
241+
const mapSeen = new Set<string>();
242242
for (const f of host.getOutput()) {
243243
assert.isFalse(mapSeen.has(f), `Already found ${f} in ${JSON.stringify(host.getOutput())}`);
244244
if (mapExpected.has(f)) {
@@ -250,7 +250,7 @@ export function checkOutputContains(host: TestServerHost, expected: readonly str
250250
}
251251

252252
export function checkOutputDoesNotContain(host: TestServerHost, expectedToBeAbsent: string[] | readonly string[]) {
253-
const mapExpectedToBeAbsent = new ts.Set(expectedToBeAbsent);
253+
const mapExpectedToBeAbsent = new Set(expectedToBeAbsent);
254254
for (const f of host.getOutput()) {
255255
assert.isFalse(mapExpectedToBeAbsent.has(f), `Contains ${f} in ${JSON.stringify(host.getOutput())}`);
256256
}
@@ -353,7 +353,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module
353353

354354
private readonly output: string[] = [];
355355

356-
private fs: ESMap<Path, FSEntry> = new ts.Map();
356+
private fs: ESMap<Path, FSEntry> = new Map();
357357
private time = timeIncrements;
358358
getCanonicalFileName: (s: string) => string;
359359
private toPath: (f: string) => Path;
@@ -1003,7 +1003,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module
10031003
}
10041004

10051005
snap(): ESMap<Path, FSEntry> {
1006-
const result = new ts.Map<Path, FSEntry>();
1006+
const result = new Map<Path, FSEntry>();
10071007
this.fs.forEach((value, key) => {
10081008
const cloneValue = clone(value);
10091009
if (isFsFolder(cloneValue)) {
@@ -1016,7 +1016,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module
10161016
}
10171017

10181018
writtenFiles?: ESMap<Path, number>;
1019-
diff(baseline: string[], base: ESMap<string, FSEntry> = new ts.Map()) {
1019+
diff(baseline: string[], base: ESMap<string, FSEntry> = new Map()) {
10201020
this.fs.forEach(newFsEntry => {
10211021
diffFsEntry(baseline, base.get(newFsEntry.path), newFsEntry, this.writtenFiles);
10221022
});
@@ -1180,7 +1180,7 @@ export type TestServerHostTrackingWrittenFiles = TestServerHost & {
11801180
export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) {
11811181
const host = inputHost as TestServerHostTrackingWrittenFiles;
11821182
const originalWriteFile = host.writeFile;
1183-
host.writtenFiles = new ts.Map<Path, number>();
1183+
host.writtenFiles = new Map<Path, number>();
11841184
host.writeFile = (fileName, content) => {
11851185
originalWriteFile.call(host, fileName, content);
11861186
const path = host.toFullPath(fileName);

0 commit comments

Comments
 (0)