1
1
// This file contains the build logic for the public repo
2
2
// @ts -check
3
+ /// <reference types="jake" />
3
4
4
5
var fs = require ( "fs" ) ;
5
6
var os = require ( "os" ) ;
@@ -171,35 +172,34 @@ var compilerFilename = "tsc.js";
171
172
var LKGCompiler = path . join ( LKGDirectory , compilerFilename ) ;
172
173
var builtLocalCompiler = path . join ( builtLocalDirectory , compilerFilename ) ;
173
174
174
- /* Compiles a file from a list of sources
175
- * @param outFile: the target file name
176
- * @param sources: an array of the names of the source files
177
- * @param prereqs: prerequisite tasks to compiling the file
178
- * @param prefixes: a list of files to prepend to the target file
179
- * @param useBuiltCompiler: true to use the built compiler, false to use the LKG
180
- * @parap {Object} opts - property bag containing auxiliary options
181
- * @param {boolean } opts.noOutFile: true to compile without using --out
182
- * @param {boolean } opts.generateDeclarations: true to compile using --declaration
183
- * @param {string } opts.outDir: value for '--outDir' command line option
184
- * @param {boolean } opts.keepComments: false to compile using --removeComments
185
- * @param {boolean } opts.preserveConstEnums: true if compiler should keep const enums in code
186
- * @param {boolean } opts.noResolve: true if compiler should not include non-rooted files in compilation
187
- * @param {boolean } opts.stripInternal: true if compiler should remove declarations marked as @internal
188
- * @param {boolean } opts.inlineSourceMap: true if compiler should inline sourceMap
189
- * @param {Array } opts.types: array of types to include in compilation
190
- * @param callback: a function to execute after the compilation process ends
191
- */
175
+ /**
176
+ * Compiles a file from a list of sources
177
+ * @param {string } outFile the target file name
178
+ * @param {string[] } sources an array of the names of the source files
179
+ * @param {string[] } prereqs prerequisite tasks to compiling the file
180
+ * @param {string[] } prefixes a list of files to prepend to the target file
181
+ * @param {boolean } useBuiltCompiler true to use the built compiler, false to use the LKG
182
+ * @param {object } [opts] property bag containing auxiliary options
183
+ * @param {boolean } [opts.noOutFile] true to compile without using --out
184
+ * @param {boolean } [opts.generateDeclarations] true to compile using --declaration
185
+ * @param {string } [opts.outDir] value for '--outDir' command line option
186
+ * @param {boolean } [opts.keepComments] false to compile using --removeComments
187
+ * @param {boolean } [opts.preserveConstEnums] true if compiler should keep const enums in code
188
+ * @param {boolean } [opts.noResolve] true if compiler should not include non-rooted files in compilation
189
+ * @param {boolean } [opts.stripInternal] true if compiler should remove declarations marked as internal
190
+ * @param {boolean } [opts.inlineSourceMap] true if compiler should inline sourceMap
191
+ * @param {string[] } [opts.types] array of types to include in compilation
192
+ * @param {string } [opts.lib] explicit libs to include.
193
+ * @param {function(): void } [callback] a function to execute after the compilation process ends
194
+ */
192
195
function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , opts , callback ) {
193
196
file ( outFile , prereqs , function ( ) {
194
- if ( process . env . USE_TRANSFORMS === "false" ) {
195
- useBuiltCompiler = false ;
196
- }
197
197
var startCompileTime = mark ( ) ;
198
198
opts = opts || { } ;
199
199
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler ;
200
- var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError --types " ;
200
+ var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError" ;
201
201
if ( opts . types ) {
202
- options += opts . types . join ( "," ) ;
202
+ options += " --types " + opts . types . join ( "," ) ;
203
203
}
204
204
options += " --pretty" ;
205
205
// Keep comments when specifically requested
@@ -236,15 +236,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
236
236
options += " --inlineSourceMap --inlineSources" ;
237
237
}
238
238
else {
239
- options += " -sourcemap" ;
239
+ options += " -- sourcemap" ;
240
240
}
241
241
}
242
242
options += " --newLine LF" ;
243
243
244
244
if ( opts . stripInternal ) {
245
245
options += " --stripInternal" ;
246
246
}
247
- options += " --target es5" ;
247
+ options += " --target es5" ;
248
248
if ( opts . lib ) {
249
249
options += " --lib " + opts . lib ;
250
250
}
@@ -362,7 +362,6 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
362
362
var buildProtocolJs = path . join ( scriptsDirectory , "buildProtocol.js" ) ;
363
363
var buildProtocolDts = path . join ( builtLocalDirectory , "protocol.d.ts" ) ;
364
364
var typescriptServicesDts = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
365
- var typesMapJson = path . join ( builtLocalDirectory , "typesMap.json" ) ;
366
365
367
366
file ( buildProtocolTs ) ;
368
367
@@ -540,7 +539,7 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js");
540
539
compileFile ( serverFile , serverSources , [ builtLocalDirectory , copyright , cancellationTokenFile , typingsInstallerFile , watchGuardFile ] . concat ( serverSources ) . concat ( servicesSources ) , /*prefixes*/ [ copyright ] , /*useBuiltCompiler*/ true , { types : [ "node" ] , preserveConstEnums : true , lib : "es6" } ) ;
541
540
var tsserverLibraryFile = path . join ( builtLocalDirectory , "tsserverlibrary.js" ) ;
542
541
var tsserverLibraryDefinitionFile = path . join ( builtLocalDirectory , "tsserverlibrary.d.ts" ) ;
543
- file ( typesMapOutputPath , function ( ) {
542
+ file ( typesMapOutputPath , /** @type { * } */ ( function ( ) {
544
543
var content = fs . readFileSync ( path . join ( serverDirectory , 'typesMap.json' ) ) ;
545
544
// Validate that it's valid JSON
546
545
try {
@@ -549,7 +548,7 @@ file(typesMapOutputPath, function() {
549
548
console . log ( "Parse error in typesMap.json: " + e ) ;
550
549
}
551
550
fs . writeFileSync ( typesMapOutputPath , content ) ;
552
- } ) ;
551
+ } ) ) ;
553
552
compileFile (
554
553
tsserverLibraryFile ,
555
554
languageServiceLibrarySources ,
@@ -693,7 +692,7 @@ desc("Builds the test infrastructure using the built compiler");
693
692
task ( "tests" , [ "local" , run ] . concat ( libraryTargets ) ) ;
694
693
695
694
function exec ( cmd , completeHandler , errorHandler ) {
696
- var ex = jake . createExec ( [ cmd ] , { windowsVerbatimArguments : true , interactive : true } ) ;
695
+ var ex = jake . createExec ( [ cmd ] , /** @type { jake.ExecOptions } */ ( { windowsVerbatimArguments : true , interactive : true } ) ) ;
697
696
// Add listeners for output and error
698
697
ex . addListener ( "stdout" , function ( output ) {
699
698
process . stdout . write ( output ) ;
@@ -1170,7 +1169,7 @@ task("lint", ["build-rules"], () => {
1170
1169
function lint ( project , cb ) {
1171
1170
const cmd = `node node_modules/tslint/bin/tslint --project ${ project } --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish` ;
1172
1171
console . log ( "Linting: " + cmd ) ;
1173
- jake . exec ( [ cmd ] , { interactive : true , windowsVerbatimArguments : true } , cb ) ;
1172
+ jake . exec ( [ cmd ] , cb , /** @type { jake.ExecOptions } */ ( { interactive : true , windowsVerbatimArguments : true } ) ) ;
1174
1173
}
1175
1174
lint ( "scripts/tslint/tsconfig.json" , ( ) => lint ( "src/tsconfig-base.json" , ( ) => {
1176
1175
if ( fold . isTravis ( ) ) console . log ( fold . end ( "lint" ) ) ;
0 commit comments