diff --git a/Gulpfile.js b/Gulpfile.js
index ead6442b81cbb..91643109ffa92 100644
--- a/Gulpfile.js
+++ b/Gulpfile.js
@@ -119,55 +119,31 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
const buildServices = (() => {
- // build typescriptServices.out.js
- const buildTypescriptServicesOut = () => buildProject("src/typescriptServices/tsconfig.json", cmdLineOptions);
-
- // create typescriptServices.js
- const createTypescriptServicesJs = () => src("built/local/typescriptServices.out.js")
- .pipe(newer("built/local/typescriptServices.js"))
- .pipe(sourcemaps.init({ loadMaps: true }))
- .pipe(prependFile(copyright))
- .pipe(rename("typescriptServices.js"))
- .pipe(sourcemaps.write(".", { includeContent: false, destPath: "built/local" }))
- .pipe(dest("built/local"));
-
- // create typescriptServices.d.ts
- const createTypescriptServicesDts = () => src("built/local/typescriptServices.out.d.ts")
- .pipe(newer("built/local/typescriptServices.d.ts"))
- .pipe(prependFile(copyright))
- .pipe(transform(content => content.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4")))
- .pipe(rename("typescriptServices.d.ts"))
- .pipe(dest("built/local"));
+ // build typescript.out.js
+ const buildTypescriptOut = () => buildProject("src/typescript/tsconfig.json", cmdLineOptions);
// create typescript.js
- const createTypescriptJs = () => src("built/local/typescriptServices.js")
+ const createTypescriptJs = () => src("built/local/typescript.out.js")
.pipe(newer("built/local/typescript.js"))
.pipe(sourcemaps.init({ loadMaps: true }))
+ .pipe(prependFile(copyright))
.pipe(rename("typescript.js"))
.pipe(sourcemaps.write(".", { includeContent: false, destPath: "built/local" }))
.pipe(dest("built/local"));
// create typescript.d.ts
- const createTypescriptDts = () => src("built/local/typescriptServices.d.ts")
+ const createTypescriptDts = () => src("built/local/typescript.out.d.ts")
.pipe(newer("built/local/typescript.d.ts"))
+ .pipe(prependFile(copyright))
+ .pipe(transform(content => content.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4")))
.pipe(append("\nexport = ts;"))
.pipe(rename("typescript.d.ts"))
.pipe(dest("built/local"));
- // create typescript_standalone.d.ts
- const createTypescriptStandaloneDts = () => src("built/local/typescriptServices.d.ts")
- .pipe(newer("built/local/typescript_standalone.d.ts"))
- .pipe(transform(content => content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"')))
- .pipe(rename("typescript_standalone.d.ts"))
- .pipe(dest("built/local"));
-
return series(
- buildTypescriptServicesOut,
- createTypescriptServicesJs,
- createTypescriptServicesDts,
+ buildTypescriptOut,
createTypescriptJs,
createTypescriptDts,
- createTypescriptStandaloneDts,
);
})();
task("services", series(preBuild, buildServices));
@@ -177,17 +153,15 @@ task("services").flags = {
};
const cleanServices = async () => {
- if (fs.existsSync("built/local/typescriptServices.tsconfig.json")) {
- await cleanProject("built/local/typescriptServices.tsconfig.json");
+ if (fs.existsSync("built/local/typescript.tsconfig.json")) {
+ await cleanProject("built/local/typescript.tsconfig.json");
}
await del([
- "built/local/typescriptServices.out.js",
- "built/local/typescriptServices.out.d.ts",
- "built/local/typescriptServices.out.tsbuildinfo",
- "built/local/typescriptServices.js",
+ "built/local/typescript.out.js",
+ "built/local/typescript.out.d.ts",
+ "built/local/typescript.out.tsbuildinfo",
"built/local/typescript.js",
"built/local/typescript.d.ts",
- "built/local/typescript_standalone.d.ts"
]);
};
cleanTasks.push(cleanServices);
@@ -511,8 +485,6 @@ const cleanBuilt = () => del("built");
const produceLKG = async () => {
const expectedFiles = [
"built/local/tsc.release.js",
- "built/local/typescriptServices.js",
- "built/local/typescriptServices.d.ts",
"built/local/tsserver.js",
"built/local/dynamicImportCompat.js",
"built/local/typescript.js",
diff --git a/scripts/VSDevMode.ps1 b/scripts/VSDevMode.ps1
index 47694286edcc1..72e7a5c3b68b9 100644
--- a/scripts/VSDevMode.ps1
+++ b/scripts/VSDevMode.ps1
@@ -37,7 +37,7 @@ if(!(Test-Path $tsRegKey)){
}
if($tsScript -ne ""){
- $tsScriptServices = "${tsScript}\typescriptServices.js"
+ $tsScriptServices = "${tsScript}\typescript.js"
$tsScriptlib = "${tsScript}\lib.d.ts"
$tsES6Scriptlib = "${tsScript}\lib.es6.d.ts"
diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts
deleted file mode 100644
index 2cc843d45785b..0000000000000
--- a/scripts/buildProtocol.ts
+++ /dev/null
@@ -1,200 +0,0 @@
-///
-
-import * as ts from "../lib/typescript";
-import * as path from "path";
-
-function endsWith(s: string, suffix: string) {
- return s.lastIndexOf(suffix, s.length - suffix.length) !== -1;
-}
-
-function isStringEnum(declaration: ts.EnumDeclaration) {
- return declaration.members.length && declaration.members.every(m => !!m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
-}
-
-class DeclarationsWalker {
- private visitedTypes: ts.Type[] = [];
- private text = "";
- private removedTypes: ts.Type[] = [];
-
- private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
- }
-
- static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
- const walker = new DeclarationsWalker(typeChecker, protocolFile);
- walker.visitTypeNodes(protocolFile);
- let text = walker.text
- ? `declare namespace ts.server.protocol {\n${walker.text}}`
- : "";
- if (walker.removedTypes) {
- text += "\ndeclare namespace ts {\n";
- text += " // these types are empty stubs for types from services and should not be used directly\n";
- for (const type of walker.removedTypes) {
- text += ` export type ${type.symbol.name} = never;\n`;
- }
- text += "}";
- }
- return text;
- }
-
- private processType(type: ts.Type): void {
- if (this.visitedTypes.indexOf(type) >= 0) {
- return;
- }
- this.visitedTypes.push(type);
- const s = type.aliasSymbol || type.getSymbol();
- if (!s) {
- return;
- }
- if (s.name === "Array" || s.name === "ReadOnlyArray") {
- // we should process type argument instead
- return this.processType((type as any).typeArguments[0]);
- }
- else {
- const declarations = s.getDeclarations();
- if (declarations) {
- for (const decl of declarations) {
- const sourceFile = decl.getSourceFile();
- if (sourceFile === this.protocolFile || /lib(\..+)?\.d.ts/.test(path.basename(sourceFile.fileName))) {
- return;
- }
- if (decl.kind === ts.SyntaxKind.EnumDeclaration && !isStringEnum(decl as ts.EnumDeclaration)) {
- this.removedTypes.push(type);
- return;
- }
- else {
- // splice declaration in final d.ts file
- const text = decl.getFullText();
- this.text += `${text}\n`;
- // recursively pull all dependencies into result dts file
-
- this.visitTypeNodes(decl);
- }
- }
- }
- }
- }
-
- private visitTypeNodes(node: ts.Node) {
- if (node.parent) {
- switch (node.parent.kind) {
- case ts.SyntaxKind.VariableDeclaration:
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.MethodSignature:
- case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.PropertySignature:
- case ts.SyntaxKind.Parameter:
- case ts.SyntaxKind.IndexSignature:
- if (((node.parent as ts.VariableDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature | ts.IndexSignatureDeclaration).type) === node) {
- this.processTypeOfNode(node);
- }
- break;
- case ts.SyntaxKind.InterfaceDeclaration:
- const heritageClauses = (node.parent as ts.InterfaceDeclaration).heritageClauses;
- if (heritageClauses) {
- if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) {
- throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`);
- }
- for (const type of heritageClauses[0].types) {
- this.processTypeOfNode(type);
- }
- }
- break;
- }
- }
- ts.forEachChild(node, n => this.visitTypeNodes(n));
- }
-
- private processTypeOfNode(node: ts.Node): void {
- if (node.kind === ts.SyntaxKind.UnionType) {
- for (const t of (node as ts.UnionTypeNode).types) {
- this.processTypeOfNode(t);
- }
- }
- else {
- const type = this.typeChecker.getTypeAtLocation(node);
- if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) {
- this.processType(type);
- }
- }
- }
-}
-
-function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptServicesDts: string) {
- const options = { target: ts.ScriptTarget.ES5, declaration: true, noResolve: false, types: [] as string[], stripInternal: true };
-
- /**
- * 1st pass - generate a program from protocol.ts and typescriptservices.d.ts and emit core version of protocol.d.ts with all internal members stripped
- * @return text of protocol.d.t.s
- */
- function getInitialDtsFileForProtocol() {
- const program = ts.createProgram([protocolTs, typeScriptServicesDts, path.join(typeScriptServicesDts, "../lib.es5.d.ts")], options);
-
- let protocolDts: string | undefined;
- const emitResult = program.emit(program.getSourceFile(protocolTs), (file, content) => {
- if (endsWith(file, ".d.ts")) {
- protocolDts = content;
- }
- });
-
- if (protocolDts === undefined) {
- const diagHost: ts.FormatDiagnosticsHost = {
- getCanonicalFileName(f) { return f; },
- getCurrentDirectory() { return "."; },
- getNewLine() { return "\r\n"; }
- };
- const diags = emitResult.diagnostics.map(d => ts.formatDiagnostic(d, diagHost)).join("\r\n");
- throw new Error(`Declaration file for protocol.ts is not generated:\r\n${diags}`);
- }
- return protocolDts;
- }
-
- const protocolFileName = "protocol.d.ts";
- /**
- * Second pass - generate a program from protocol.d.ts and typescriptservices.d.ts, then augment core protocol.d.ts with extra types from typescriptservices.d.ts
- */
- function getProgramWithProtocolText(protocolDts: string, includeTypeScriptServices: boolean) {
- const host = ts.createCompilerHost(options);
- const originalGetSourceFile = host.getSourceFile;
- host.getSourceFile = (fileName) => {
- if (fileName === protocolFileName) {
- return ts.createSourceFile(fileName, protocolDts, options.target);
- }
- return originalGetSourceFile.apply(host, [fileName, ts.ScriptTarget.Latest]);
- };
- const rootFiles = includeTypeScriptServices ? [protocolFileName, typeScriptServicesDts] : [protocolFileName];
- return ts.createProgram(rootFiles, options, host);
- }
-
- let protocolDts = getInitialDtsFileForProtocol();
- const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true);
-
- const protocolFile = program.getSourceFile("protocol.d.ts")!;
- const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile);
- if (extraDeclarations) {
- protocolDts += extraDeclarations;
- }
- protocolDts += "\nimport protocol = ts.server.protocol;";
- protocolDts += "\nexport = protocol;";
- protocolDts += "\nexport as namespace protocol;";
-
- // do sanity check and try to compile generated text as standalone program
- const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
- const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
-
- ts.sys.writeFile(outputFile, protocolDts);
-
- if (diagnostics.length) {
- const flattenedDiagnostics = diagnostics.map(d => `${ts.flattenDiagnosticMessageText(d.messageText, "\n")} at ${d.file ? d.file.fileName : ""} line ${d.start}`).join("\n");
- throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
- }
-}
-
-if (process.argv.length < 5) {
- console.log(`Expected 3 arguments: path to 'protocol.ts', path to 'typescriptservices.d.ts' and path to output file`);
- process.exit(1);
-}
-
-const protocolTs = process.argv[2];
-const typeScriptServicesDts = process.argv[3];
-const outputFile = process.argv[4];
-writeProtocolFile(outputFile, protocolTs, typeScriptServicesDts);
diff --git a/scripts/createPlaygroundBuild.js b/scripts/createPlaygroundBuild.js
index 31fe5af92dd8e..38ae0289fe068 100644
--- a/scripts/createPlaygroundBuild.js
+++ b/scripts/createPlaygroundBuild.js
@@ -7,7 +7,7 @@
// This script does two things:
//
-// - Listens to changes to the built version of TypeScript (via a filewatcher on `built/local/typescriptServices.js`)
+// - Listens to changes to the built version of TypeScript (via a filewatcher on `built/local/typescript.js`)
// these trigger creating monaco-typescript compatible builds of TypeScript at `internal/lib/typescriptServices.jsĀ§
//
// - Creates a HTTP server which the playground uses. The webserver almost exclusively re-directs requests to
@@ -60,7 +60,7 @@ function updateTSDist() {
);
let tsServices = fs
- .readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.js'))
+ .readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescript.js'))
.toString();
// Ensure we never run into the node system...
@@ -155,13 +155,8 @@ function updateTSDist() {
);
let dtsServices = fs
- .readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.d.ts'))
+ .readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescript.d.ts'))
.toString();
- dtsServices += `
- // MONACOCHANGE
- export = ts;
- // END MONACOCHANGE
- `;
fs.writeFileSync(
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'),
generatedNote + dtsServices
@@ -271,7 +266,7 @@ function updateTSDist() {
/// End of import
}
-const services = path.join(__dirname, '../built/local/typescriptServices.js');
+const services = path.join(__dirname, '../built/local/typescript.js');
fs.watchFile(services, () =>{
console.log("Updating the monaco build")
updateTSDist()
diff --git a/scripts/produceLKG.ts b/scripts/produceLKG.ts
index e4e37df028e6f..5a304d4153500 100644
--- a/scripts/produceLKG.ts
+++ b/scripts/produceLKG.ts
@@ -4,6 +4,7 @@ import * as childProcess from "child_process";
import * as fs from "fs-extra";
import * as path from "path";
import * as glob from "glob";
+import * as del from "del";
const root = path.join(__dirname, "..");
const source = path.join(root, "built/local");
@@ -12,12 +13,13 @@ const copyright = fs.readFileSync(path.join(__dirname, "../CopyrightNotice.txt")
async function produceLKG() {
console.log(`Building LKG from ${source} to ${dest}`);
+ await del(`${dest.replace(/\\/g, "/")}/**`, { ignore: ["**/README.md"] });
+ await fs.mkdirp(dest);
await copyLibFiles();
await copyLocalizedDiagnostics();
await copyTypesMap();
await copyScriptOutputs();
await copyDeclarationOutputs();
- await buildProtocol();
await writeGitAttributes();
}
@@ -44,20 +46,6 @@ async function copyTypesMap() {
await copyFromBuiltLocal("typesMap.json"); // Cannot accommodate copyright header
}
-async function buildProtocol() {
- const protocolScript = path.join(__dirname, "buildProtocol.js");
- if (!fs.existsSync(protocolScript)) {
- throw new Error(`Expected protocol script ${protocolScript} to exist`);
- }
-
- const protocolInput = path.join(__dirname, "../src/server/protocol.ts");
- const protocolServices = path.join(source, "typescriptServices.d.ts");
- const protocolOutput = path.join(dest, "protocol.d.ts");
-
- console.log(`Building ${protocolOutput}...`);
- await exec(protocolScript, [protocolInput, protocolServices, protocolOutput]);
-}
-
async function copyScriptOutputs() {
await copyWithCopyright("cancellationToken.js");
await copyWithCopyright("tsc.release.js", "tsc.js");
@@ -65,7 +53,6 @@ async function copyScriptOutputs() {
await copyWithCopyright("dynamicImportCompat.js");
await copyFromBuiltLocal("tsserverlibrary.js"); // copyright added by build
await copyFromBuiltLocal("typescript.js"); // copyright added by build
- await copyFromBuiltLocal("typescriptServices.js"); // copyright added by build
await copyWithCopyright("typingsInstaller.js");
await copyWithCopyright("watchGuard.js");
}
@@ -73,7 +60,6 @@ async function copyScriptOutputs() {
async function copyDeclarationOutputs() {
await copyFromBuiltLocal("tsserverlibrary.d.ts"); // copyright added by build
await copyFromBuiltLocal("typescript.d.ts"); // copyright added by build
- await copyFromBuiltLocal("typescriptServices.d.ts"); // copyright added by build
}
async function writeGitAttributes() {
diff --git a/src/typescriptServices/tsconfig.json b/src/typescript/tsconfig.json
similarity index 75%
rename from src/typescriptServices/tsconfig.json
rename to src/typescript/tsconfig.json
index e2ec0c2700988..7a171a44ccddc 100644
--- a/src/typescriptServices/tsconfig.json
+++ b/src/typescript/tsconfig.json
@@ -1,10 +1,10 @@
{
"extends": "../tsconfig-library-base",
"compilerOptions": {
- "outFile": "../../built/local/typescriptServices.out.js"
+ "outFile": "../../built/local/typescript.out.js"
},
"files": [
- "typescriptServices.ts"
+ "typescript.ts"
],
"references": [
{ "path": "../compiler", "prepend": true },
diff --git a/src/typescriptServices/typescriptServices.ts b/src/typescript/typescript.ts
similarity index 100%
rename from src/typescriptServices/typescriptServices.ts
rename to src/typescript/typescript.ts