Skip to content

Commit 27616dd

Browse files
authored
Move codefix types into services/types.ts (#35506)
* Move codefix types into services/types.ts * Also split apart refactorProvider * Move all meanings of DocumentHighlights into one file * Use setter for object allocator * Remove unneeded namespace reference * Remove some shorthand references to nonlocal namespace variables * Convert WatchType string enum to a structure that can be merged across modules * Rename harness to harnessIO * Move accidental globals into namespace * Remove unused globals * Suppress lints - these qualifiers are needed for the migration to go smoothly * Hide global declaration
1 parent 9a766c3 commit 27616dd

19 files changed

+723
-705
lines changed

src/compiler/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4958,6 +4958,10 @@ namespace ts {
49584958
getSourceMapSourceConstructor: () => <any>SourceMapSource,
49594959
};
49604960

4961+
export function setObjectAllocator(alloc: ObjectAllocator) {
4962+
objectAllocator = alloc;
4963+
}
4964+
49614965
export function formatStringFromArgs(text: string, args: ArrayLike<string | number>, baseIndex = 0): string {
49624966
return text.replace(/{(\d+)}/g, (_match, index: string) => "" + Debug.assertDefined(args[+index + baseIndex]));
49634967
}

src/compiler/watch.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,23 @@ namespace ts {
243243
};
244244
}
245245

246-
export const enum WatchType {
247-
ConfigFile = "Config file",
248-
SourceFile = "Source file",
249-
MissingFile = "Missing file",
250-
WildcardDirectory = "Wild card directory",
251-
FailedLookupLocations = "Failed Lookup Locations",
252-
TypeRoots = "Type roots"
246+
export type WatchType = WatchTypeRegistry[keyof WatchTypeRegistry];
247+
export const WatchType: WatchTypeRegistry = {
248+
ConfigFile: "Config file",
249+
SourceFile: "Source file",
250+
MissingFile: "Missing file",
251+
WildcardDirectory: "Wild card directory",
252+
FailedLookupLocations: "Failed Lookup Locations",
253+
TypeRoots: "Type roots"
254+
};
255+
256+
export interface WatchTypeRegistry {
257+
ConfigFile: "Config file",
258+
SourceFile: "Source file",
259+
MissingFile: "Missing file",
260+
WildcardDirectory: "Wild card directory",
261+
FailedLookupLocations: "Failed Lookup Locations",
262+
TypeRoots: "Type roots"
253263
}
254264

255265
interface WatchFactory<X, Y = undefined> extends ts.WatchFactory<X, Y> {

src/harness/harnessGlobals.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,4 @@ var assert: typeof _chai.assert = _chai.assert;
2727
}
2828
};
2929
}
30-
31-
var global: NodeJS.Global = Function("return this").call(undefined); // eslint-disable-line no-new-func
32-
33-
declare var window: {};
34-
declare var XMLHttpRequest: new() => XMLHttpRequest;
35-
36-
interface XMLHttpRequest {
37-
readonly readyState: number;
38-
readonly responseText: string;
39-
readonly status: number;
40-
readonly statusText: string;
41-
open(method: string, url: string, async?: boolean, user?: string, password?: string): void;
42-
send(data?: string): void;
43-
setRequestHeader(header: string, value: string): void;
44-
getAllResponseHeaders(): string;
45-
getResponseHeader(header: string): string | null;
46-
overrideMimeType(mime: string): void;
47-
}
4830
/* eslint-enable no-var */
File renamed without changes.

src/harness/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"sourceMapRecorder.ts",
3434
"harnessGlobals.ts",
3535
"harnessUtils.ts",
36-
"harness.ts",
36+
"harnessIO.ts",
3737
"harnessLanguageService.ts",
3838
"virtualFileSystemWithWatch.ts",
3939
"fourslash.ts",

src/harness/typeWriter.ts

Lines changed: 150 additions & 148 deletions
Large diffs are not rendered by default.

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ namespace ts.server {
16251625
totalNonTsFileSize += this.host.getFileSize(fileName);
16261626

16271627
if (totalNonTsFileSize > maxProgramSizeForNonTsFiles || totalNonTsFileSize > availableSpace) {
1628-
this.logger.info(getExceedLimitMessage({ propertyReader, hasTSFileExtension, host: this.host }, totalNonTsFileSize));
1628+
this.logger.info(getExceedLimitMessage({ propertyReader, hasTSFileExtension: ts.hasTSFileExtension, host: this.host }, totalNonTsFileSize)); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
16291629
// Keep the size as zero since it's disabled
16301630
return fileName;
16311631
}
@@ -1694,7 +1694,7 @@ namespace ts.server {
16941694
configFileName: configFileName(),
16951695
projectType: project instanceof ExternalProject ? "external" : "configured",
16961696
languageServiceEnabled: project.languageServiceEnabled,
1697-
version,
1697+
version: ts.version, // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
16981698
};
16991699
this.eventHandler({ eventName: ProjectInfoTelemetryEvent, data });
17001700

src/server/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ namespace ts.server.protocol {
15751575
/**
15761576
* List of last known projects
15771577
*/
1578-
knownProjects: protocol.ProjectVersionInfo[];
1578+
knownProjects: ProjectVersionInfo[];
15791579
}
15801580

15811581
/**

src/server/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ namespace ts.server {
21472147

21482148
private handlers = createMapFromTemplate<(request: protocol.Request) => HandlerResponse>({
21492149
[CommandNames.Status]: () => {
2150-
const response: protocol.StatusResponseBody = { version };
2150+
const response: protocol.StatusResponseBody = { version: ts.version }; // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
21512151
return this.requiredResponse(response);
21522152
},
21532153
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {

src/server/watchType.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
/* @internal */
22
namespace ts {
33
// Additional tsserver specific watch information
4-
export const enum WatchType {
5-
ClosedScriptInfo = "Closed Script info",
6-
ConfigFileForInferredRoot = "Config file for the inferred project root",
7-
NodeModulesForClosedScriptInfo = "node_modules for closed script infos in them",
8-
MissingSourceMapFile = "Missing source map file",
9-
NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root",
10-
MissingGeneratedFile = "Missing generated file",
11-
PackageJsonFile = "package.json file for import suggestions"
4+
export interface WatchTypeRegistry {
5+
ClosedScriptInfo: "Closed Script info",
6+
ConfigFileForInferredRoot: "Config file for the inferred project root",
7+
NodeModulesForClosedScriptInfo: "node_modules for closed script infos in them",
8+
MissingSourceMapFile: "Missing source map file",
9+
NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
10+
MissingGeneratedFile: "Missing generated file",
11+
PackageJsonFile: "package.json file for import suggestions"
1212
}
13+
WatchType.ClosedScriptInfo = "Closed Script info";
14+
WatchType.ConfigFileForInferredRoot = "Config file for the inferred project root";
15+
WatchType.NodeModulesForClosedScriptInfo = "node_modules for closed script infos in them";
16+
WatchType.MissingSourceMapFile = "Missing source map file";
17+
WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root";
18+
WatchType.MissingGeneratedFile = "Missing generated file";
19+
WatchType.PackageJsonFile = "package.json file for import suggestions";
1320
}

0 commit comments

Comments
 (0)