Skip to content

Commit 1aff002

Browse files
committed
Merge branch 'joelday-tsserverlibrary-as-module'
2 parents 4086bd1 + ccc85c4 commit 1aff002

File tree

11 files changed

+81
-44
lines changed

11 files changed

+81
-44
lines changed

Gulpfile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
471471
js.pipe(prependCopyright())
472472
.pipe(sourcemaps.write("."))
473473
.pipe(gulp.dest(".")),
474-
dts.pipe(prependCopyright())
474+
dts.pipe(prependCopyright(/*outputCopyright*/true))
475+
.pipe(insert.transform((content) => {
476+
return content + "\r\nexport = ts;\r\nexport as namespace ts;";
477+
}))
475478
.pipe(gulp.dest("."))
476479
]);
477480
});

Jakefile.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,31 +183,36 @@ var servicesSources = [
183183
return path.join(servicesDirectory, f);
184184
}));
185185

186-
var serverCoreSources = [
187-
"types.d.ts",
188-
"shared.ts",
189-
"utilities.ts",
190-
"scriptVersionCache.ts",
191-
"typingsCache.ts",
192-
"scriptInfo.ts",
186+
var baseServerCoreSources = [
187+
"editorServices.ts",
193188
"lsHost.ts",
194189
"project.ts",
195-
"editorServices.ts",
196190
"protocol.ts",
191+
"scriptInfo.ts",
192+
"scriptVersionCache.ts",
197193
"session.ts",
198-
"server.ts"
194+
"shared.ts",
195+
"types.ts",
196+
"typingsCache.ts",
197+
"utilities.ts",
199198
].map(function (f) {
200199
return path.join(serverDirectory, f);
201200
});
202201

202+
var serverCoreSources = [
203+
"server.ts"
204+
].map(function (f) {
205+
return path.join(serverDirectory, f);
206+
}).concat(baseServerCoreSources);
207+
203208
var cancellationTokenSources = [
204209
"cancellationToken.ts"
205210
].map(function (f) {
206211
return path.join(cancellationTokenDirectory, f);
207212
});
208213

209214
var typingsInstallerSources = [
210-
"../types.d.ts",
215+
"../types.ts",
211216
"../shared.ts",
212217
"typingsInstaller.ts",
213218
"nodeTypingsInstaller.ts"
@@ -216,20 +221,7 @@ var typingsInstallerSources = [
216221
});
217222

218223
var serverSources = serverCoreSources.concat(servicesSources);
219-
220-
var languageServiceLibrarySources = [
221-
"protocol.ts",
222-
"utilities.ts",
223-
"scriptVersionCache.ts",
224-
"scriptInfo.ts",
225-
"lsHost.ts",
226-
"project.ts",
227-
"editorServices.ts",
228-
"session.ts",
229-
230-
].map(function (f) {
231-
return path.join(serverDirectory, f);
232-
}).concat(servicesSources);
224+
var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources);
233225

234226
var harnessCoreSources = [
235227
"harness.ts",
@@ -727,7 +719,18 @@ compileFile(
727719
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
728720
/*prefixes*/[copyright],
729721
/*useBuiltCompiler*/ true,
730-
{ noOutFile: false, generateDeclarations: true });
722+
{ noOutFile: false, generateDeclarations: true, stripInternal: true },
723+
/*callback*/ function () {
724+
prependFile(copyright, tsserverLibraryDefinitionFile);
725+
726+
// Appending exports at the end of the server library
727+
var tsserverLibraryDefinitionFileContents =
728+
fs.readFileSync(tsserverLibraryDefinitionFile).toString() +
729+
"\r\nexport = ts;" +
730+
"\r\nexport as namespace ts;";
731+
732+
fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents);
733+
});
731734

732735
// Local target to build the language service server library
733736
desc("Builds language service server library");

src/server/editorServices.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ namespace ts.server {
293293
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory());
294294
}
295295

296+
/* @internal */
296297
getChangedFiles_TestOnly() {
297298
return this.changedFiles;
298299
}
@@ -1274,6 +1275,7 @@ namespace ts.server {
12741275
}
12751276
}
12761277

1278+
/* @internal */
12771279
synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[] {
12781280
const files: ProjectFilesWithTSDiagnostics[] = [];
12791281
this.collectChanges(knownProjects, this.externalProjects, files);
@@ -1282,6 +1284,7 @@ namespace ts.server {
12821284
return files;
12831285
}
12841286

1287+
/* @internal */
12851288
applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void {
12861289
const recordChangedFiles = changedFiles && !openFiles && !closedFiles;
12871290
if (openFiles) {

src/server/project.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace ts.server {
5858
return counts.ts === 0 && counts.tsx === 0;
5959
}
6060

61+
/* @internal */
6162
export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles {
6263
projectErrors: Diagnostic[];
6364
}
@@ -593,6 +594,7 @@ namespace ts.server {
593594
return false;
594595
}
595596

597+
/* @internal */
596598
getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics {
597599
this.updateGraph();
598600

src/server/session.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,50 +88,65 @@ namespace ts.server {
8888

8989
export namespace CommandNames {
9090
export const Brace: protocol.CommandTypes.Brace = "brace";
91+
/* @internal */
9192
export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full";
9293
export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion";
9394
export const Change: protocol.CommandTypes.Change = "change";
9495
export const Close: protocol.CommandTypes.Close = "close";
9596
export const Completions: protocol.CommandTypes.Completions = "completions";
97+
/* @internal */
9698
export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full";
9799
export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails";
98100
export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
99101
export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile";
100102
export const Configure: protocol.CommandTypes.Configure = "configure";
101103
export const Definition: protocol.CommandTypes.Definition = "definition";
104+
/* @internal */
102105
export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full";
103106
export const Exit: protocol.CommandTypes.Exit = "exit";
104107
export const Format: protocol.CommandTypes.Format = "format";
105108
export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey";
109+
/* @internal */
106110
export const FormatFull: protocol.CommandTypes.FormatFull = "format-full";
111+
/* @internal */
107112
export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full";
113+
/* @internal */
108114
export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full";
109115
export const Geterr: protocol.CommandTypes.Geterr = "geterr";
110116
export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject";
111117
export const Implementation: protocol.CommandTypes.Implementation = "implementation";
118+
/* @internal */
112119
export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full";
113120
export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync";
114121
export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
115122
export const NavBar: protocol.CommandTypes.NavBar = "navbar";
123+
/* @internal */
116124
export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full";
117125
export const NavTree: protocol.CommandTypes.NavTree = "navtree";
118126
export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full";
119127
export const Navto: protocol.CommandTypes.Navto = "navto";
128+
/* @internal */
120129
export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full";
121130
export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences";
122131
export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights";
132+
/* @internal */
123133
export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full";
124134
export const Open: protocol.CommandTypes.Open = "open";
125135
export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo";
136+
/* @internal */
126137
export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full";
127138
export const References: protocol.CommandTypes.References = "references";
139+
/* @internal */
128140
export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full";
129141
export const Reload: protocol.CommandTypes.Reload = "reload";
130142
export const Rename: protocol.CommandTypes.Rename = "rename";
143+
/* @internal */
131144
export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full";
145+
/* @internal */
132146
export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full";
133147
export const Saveto: protocol.CommandTypes.Saveto = "saveto";
134148
export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp";
149+
/* @internal */
135150
export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full";
136151
export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition";
137152
export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo";
@@ -140,19 +155,28 @@ namespace ts.server {
140155
export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject";
141156
export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects";
142157
export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject";
158+
/* @internal */
143159
export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList";
160+
/* @internal */
144161
export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
162+
/* @internal */
145163
export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
164+
/* @internal */
146165
export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup";
166+
/* @internal */
147167
export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans";
148168
export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments";
149169
export const Indentation: protocol.CommandTypes.Indentation = "indentation";
150170
export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate";
171+
/* @internal */
151172
export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
173+
/* @internal */
152174
export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan";
175+
/* @internal */
153176
export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement";
154177
export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
155178
export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes";
179+
/* @internal */
156180
export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full";
157181
export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes";
158182
}

src/server/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="types.d.ts" />
1+
/// <reference path="types.ts" />
22

33
namespace ts.server {
44
export const ActionSet: ActionSet = "action::set";

src/server/tsconfig.library.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
{
22
"compilerOptions": {
33
"noImplicitAny": true,
4-
"removeComments": true,
4+
"noImplicitThis": true,
55
"preserveConstEnums": true,
6+
"pretty": true,
67
"outFile": "../../built/local/tsserverlibrary.js",
78
"sourceMap": true,
89
"stripInternal": true,
9-
"declaration": true,
10-
"types": [],
1110
"target": "es5",
1211
"noUnusedLocals": true,
13-
"noUnusedParameters": true
12+
"noUnusedParameters": true,
13+
"declaration": true
1414
},
1515
"files": [
16-
"../services/shims.ts",
17-
"../services/utilities.ts",
18-
"shared.ts",
19-
"utilities.ts",
20-
"scriptVersionCache.ts",
16+
"editorServices.ts",
17+
"lsHost.ts",
18+
"project.ts",
19+
"protocol.ts",
2120
"scriptInfo.ts",
22-
"lshost.ts",
21+
"scriptVersionCache.ts",
22+
"session.ts",
23+
"shared.ts",
24+
"types.ts",
2325
"typingsCache.ts",
24-
"project.ts",
25-
"editorServices.ts",
26-
"protocol.d.ts",
27-
"session.ts"
26+
"utilities.ts",
27+
"../services/shims.ts",
28+
"../services/utilities.ts"
2829
]
2930
}

src/server/types.d.ts renamed to src/server/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ declare namespace ts.server {
8282
readonly installSuccess: boolean;
8383
}
8484

85+
/* @internal */
8586
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
8687
writeFile(path: string, content: string): void;
8788
createDirectory(path: string): void;

src/server/typingsInstaller/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"noUnusedParameters": true
1717
},
1818
"files": [
19-
"../types.d.ts",
19+
"../types.ts",
2020
"../shared.ts",
2121
"typingsInstaller.ts",
2222
"nodeTypingsInstaller.ts"

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="../../compiler/core.ts" />
22
/// <reference path="../../compiler/moduleNameResolver.ts" />
33
/// <reference path="../../services/jsTyping.ts"/>
4-
/// <reference path="../types.d.ts"/>
4+
/// <reference path="../types.ts"/>
55
/// <reference path="../shared.ts"/>
66

77
namespace ts.server.typingsInstaller {

0 commit comments

Comments
 (0)