@@ -34,6 +34,14 @@ const gulp = helpMaker(originalGulp);
3434
3535Error . stackTraceLimit = 1000 ;
3636
37+ /**
38+ * This regexp exists to capture our const enums and replace them with normal enums in our public API
39+ * - this is fine since we compile with preserveConstEnums, and ensures our consumers are not locked
40+ * to the TS version they compile with.
41+ */
42+ const constEnumCaptureRegexp = / ^ ( \s * ) ( e x p o r t ) ? c o n s t e n u m ( \S + ) { ( \s * ) $ / gm;
43+ const constEnumReplacement = "$1$2enum $3 {$4" ;
44+
3745const cmdLineOptions = minimist ( process . argv . slice ( 2 ) , {
3846 boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" ] ,
3947 string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" , "timeout" ] ,
@@ -261,8 +269,8 @@ function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): ts
261269 }
262270 if ( ! useDebugMode ) {
263271 if ( copy . removeComments === undefined ) copy . removeComments = true ;
264- copy . newLine = "lf" ;
265272 }
273+ copy . newLine = "lf" ;
266274 if ( useBuiltCompiler === true ) {
267275 copy . typescript = require ( "./built/local/typescript.js" ) ;
268276 }
@@ -432,7 +440,7 @@ gulp.task(servicesFile, /*help*/ false, ["lib", "generate-diagnostics"], () => {
432440 const completedDts = dts . pipe ( prependCopyright ( /*outputCopyright*/ true ) )
433441 . pipe ( insert . transform ( ( contents , file ) => {
434442 file . path = standaloneDefinitionsFile ;
435- return contents . replace ( / ^ ( \s * ) ( e x p o r t ) ? c o n s t e n u m ( \S + ) { ( \s * ) $ / gm , "$1$2enum $3 {$4" ) ;
443+ return contents . replace ( constEnumCaptureRegexp , constEnumReplacement ) ;
436444 } ) ) ;
437445 return merge2 ( [
438446 completedJs ,
@@ -442,7 +450,7 @@ gulp.task(servicesFile, /*help*/ false, ["lib", "generate-diagnostics"], () => {
442450 completedDts . pipe ( clone ( ) )
443451 . pipe ( insert . transform ( ( content , file ) => {
444452 file . path = nodeDefinitionsFile ;
445- return content + "\r\ nexport = ts;" ;
453+ return content + "\nexport = ts;" ;
446454 } ) )
447455 . pipe ( gulp . dest ( "src/services" ) ) ,
448456 completedDts . pipe ( clone ( ) )
@@ -509,7 +517,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do
509517 . pipe ( gulp . dest ( "src/server" ) ) ,
510518 dts . pipe ( prependCopyright ( /*outputCopyright*/ true ) )
511519 . pipe ( insert . transform ( ( content ) => {
512- return content + "\r\ nexport = ts;\r \nexport as namespace ts;" ;
520+ return content . replace ( constEnumCaptureRegexp , constEnumReplacement ) + "\nexport = ts;\nexport as namespace ts;" ;
513521 } ) )
514522 . pipe ( gulp . dest ( "src/server" ) )
515523 ] ) ;
@@ -588,7 +596,7 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
588596
589597// Task to build the tests infrastructure using the built compiler
590598const run = path . join ( builtLocalDirectory , "run.js" ) ;
591- gulp . task ( run , /*help*/ false , [ servicesFile ] , ( ) => {
599+ gulp . task ( run , /*help*/ false , [ servicesFile , tsserverLibraryFile ] , ( ) => {
592600 const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
593601 return testProject . src ( )
594602 . pipe ( newer ( run ) )
0 commit comments