From 105acf7d25891db95fd04b200c89bc36542fb8d3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 15 Mar 2019 13:19:18 -0700 Subject: [PATCH] Update LKG. --- lib/enu/diagnosticMessages.generated.json.lcg | 12 +-- lib/tsc.js | 78 ++++++++------- lib/tsserver.js | 94 +++++++++++-------- lib/tsserverlibrary.js | 94 +++++++++++-------- lib/typescript.js | 94 +++++++++++-------- lib/typescriptServices.js | 94 +++++++++++-------- lib/typingsInstaller.js | 84 ++++++++++------- 7 files changed, 327 insertions(+), 223 deletions(-) diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index aaa5c275919..9e99ba990da 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -2043,6 +2043,12 @@ + + + + + + @@ -2067,12 +2073,6 @@ - - - - - - diff --git a/lib/tsc.js b/lib/tsc.js index 08361406dea..d0cef6fa5c9 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -1240,6 +1240,8 @@ var ts; ts.returnFalse = returnFalse; function returnTrue() { return true; } ts.returnTrue = returnTrue; + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; function identity(x) { return x; } ts.identity = identity; function toLowerCase(x) { return x.toLowerCase(); } @@ -4331,7 +4333,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -8980,21 +8982,25 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -39197,6 +39203,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274) { return; } @@ -46674,7 +46681,7 @@ var ts; var promisedType = getPromisedTypeOfPromise(returnType); var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -48812,7 +48819,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418) { + if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -53573,7 +53580,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -67473,18 +67480,19 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts"); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts"); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json"); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" : ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ? ".jsx" : @@ -67542,6 +67550,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -67893,11 +67904,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -67937,7 +67949,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, undefined, false, ts.getTransformers(config.options)); return outputFiles; @@ -72496,7 +72508,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -72793,7 +72805,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { var path = toPath(f); if (getSourceFileByPath(path)) return true; @@ -73788,14 +73801,15 @@ var ts; } verifyProjectReferences(); if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + if (file.isDeclarationFile) + continue; + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -74132,7 +74146,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -75130,7 +75144,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -76855,7 +76869,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -77094,12 +77108,12 @@ var ts; newestInputFileTime = inputTime; } } - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate; var newestOutputFileName = "(none)"; diff --git a/lib/tsserver.js b/lib/tsserver.js index 6802caeac6e..9d4b5bcf89a 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -1443,6 +1443,9 @@ var ts; /** Do nothing and return true */ function returnTrue() { return true; } ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; /** Returns its argument. */ function identity(x) { return x; } ts.identity = identity; @@ -6386,7 +6389,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -11540,23 +11543,27 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -46846,6 +46853,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } @@ -55857,7 +55865,7 @@ var ts; // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -58277,7 +58285,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { + if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -63381,7 +63389,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -82969,19 +82977,20 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : @@ -83041,6 +83050,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -83431,11 +83443,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -83476,7 +83489,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); return outputFiles; @@ -88486,7 +88499,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -88875,7 +88888,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -89996,14 +90010,17 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + // Ignore declaration files + if (file.isDeclarationFile) + continue; + // Ignore json file thats from project reference + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -90361,7 +90378,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -91627,7 +91644,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -93600,7 +93617,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -93852,13 +93869,14 @@ var ts; newestInputFileTime = inputTime; } } - // Collect the expected outputs of this project - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + // Container if no files are specified in the project + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + // Collect the expected outputs of this project + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); // Now see if all outputs are newer than the newest input var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate; @@ -119186,9 +119204,9 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var convertToNamedParameters; - (function (convertToNamedParameters) { - var refactorName = "Convert to named parameters"; + var convertParamsToDestructuredObject; + (function (convertParamsToDestructuredObject) { + var refactorName = "Convert parameters to destructured object"; var minimumParameterLength = 2; refactor.registerRefactor(refactorName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { @@ -119199,7 +119217,7 @@ var ts; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker()); if (!functionDeclaration) return ts.emptyArray; - var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_to_named_parameters); + var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object); return [{ name: refactorName, description: description, @@ -119582,7 +119600,7 @@ var ts; return ts.Debug.assertNever(functionDeclaration); } } - })(convertToNamedParameters = refactor.convertToNamedParameters || (refactor.convertToNamedParameters = {})); + })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 563677194d6..de2a5b55d12 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -1442,6 +1442,9 @@ var ts; /** Do nothing and return true */ function returnTrue() { return true; } ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; /** Returns its argument. */ function identity(x) { return x; } ts.identity = identity; @@ -6385,7 +6388,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -11539,23 +11542,27 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -46845,6 +46852,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } @@ -55856,7 +55864,7 @@ var ts; // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -58276,7 +58284,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { + if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -63380,7 +63388,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -82968,19 +82976,20 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : @@ -83040,6 +83049,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -83430,11 +83442,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -83475,7 +83488,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); return outputFiles; @@ -88485,7 +88498,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -88874,7 +88887,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -89995,14 +90009,17 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + // Ignore declaration files + if (file.isDeclarationFile) + continue; + // Ignore json file thats from project reference + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -90360,7 +90377,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -91626,7 +91643,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -93599,7 +93616,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -93851,13 +93868,14 @@ var ts; newestInputFileTime = inputTime; } } - // Collect the expected outputs of this project - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + // Container if no files are specified in the project + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + // Collect the expected outputs of this project + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); // Now see if all outputs are newer than the newest input var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate; @@ -119525,9 +119543,9 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var convertToNamedParameters; - (function (convertToNamedParameters) { - var refactorName = "Convert to named parameters"; + var convertParamsToDestructuredObject; + (function (convertParamsToDestructuredObject) { + var refactorName = "Convert parameters to destructured object"; var minimumParameterLength = 2; refactor.registerRefactor(refactorName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { @@ -119538,7 +119556,7 @@ var ts; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker()); if (!functionDeclaration) return ts.emptyArray; - var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_to_named_parameters); + var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object); return [{ name: refactorName, description: description, @@ -119921,7 +119939,7 @@ var ts; return ts.Debug.assertNever(functionDeclaration); } } - })(convertToNamedParameters = refactor.convertToNamedParameters || (refactor.convertToNamedParameters = {})); + })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; diff --git a/lib/typescript.js b/lib/typescript.js index 5fb55a7ca9c..45298df2cca 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -1433,6 +1433,9 @@ var ts; /** Do nothing and return true */ function returnTrue() { return true; } ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; /** Returns its argument. */ function identity(x) { return x; } ts.identity = identity; @@ -6376,7 +6379,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -11530,23 +11533,27 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -46836,6 +46843,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } @@ -55847,7 +55855,7 @@ var ts; // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -58267,7 +58275,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { + if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -63371,7 +63379,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -82959,19 +82967,20 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : @@ -83031,6 +83040,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -83421,11 +83433,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -83466,7 +83479,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); return outputFiles; @@ -88476,7 +88489,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -88865,7 +88878,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -89986,14 +90000,17 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + // Ignore declaration files + if (file.isDeclarationFile) + continue; + // Ignore json file thats from project reference + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -90351,7 +90368,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -91617,7 +91634,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -93590,7 +93607,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -93842,13 +93859,14 @@ var ts; newestInputFileTime = inputTime; } } - // Collect the expected outputs of this project - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + // Container if no files are specified in the project + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + // Collect the expected outputs of this project + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); // Now see if all outputs are newer than the newest input var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate; @@ -119516,9 +119534,9 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var convertToNamedParameters; - (function (convertToNamedParameters) { - var refactorName = "Convert to named parameters"; + var convertParamsToDestructuredObject; + (function (convertParamsToDestructuredObject) { + var refactorName = "Convert parameters to destructured object"; var minimumParameterLength = 2; refactor.registerRefactor(refactorName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { @@ -119529,7 +119547,7 @@ var ts; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker()); if (!functionDeclaration) return ts.emptyArray; - var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_to_named_parameters); + var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object); return [{ name: refactorName, description: description, @@ -119912,7 +119930,7 @@ var ts; return ts.Debug.assertNever(functionDeclaration); } } - })(convertToNamedParameters = refactor.convertToNamedParameters || (refactor.convertToNamedParameters = {})); + })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7e76ff8948e..406d3c5fd20 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -1433,6 +1433,9 @@ var ts; /** Do nothing and return true */ function returnTrue() { return true; } ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; /** Returns its argument. */ function identity(x) { return x; } ts.identity = identity; @@ -6376,7 +6379,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -11530,23 +11533,27 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -46836,6 +46843,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } @@ -55847,7 +55855,7 @@ var ts; // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -58267,7 +58275,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { + if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -63371,7 +63379,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -82959,19 +82967,20 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : @@ -83031,6 +83040,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -83421,11 +83433,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -83466,7 +83479,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); return outputFiles; @@ -88476,7 +88489,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -88865,7 +88878,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -89986,14 +90000,17 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + // Ignore declaration files + if (file.isDeclarationFile) + continue; + // Ignore json file thats from project reference + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -90351,7 +90368,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -91617,7 +91634,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -93590,7 +93607,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -93842,13 +93859,14 @@ var ts; newestInputFileTime = inputTime; } } - // Collect the expected outputs of this project - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + // Container if no files are specified in the project + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + // Collect the expected outputs of this project + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); // Now see if all outputs are newer than the newest input var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate; @@ -119516,9 +119534,9 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var convertToNamedParameters; - (function (convertToNamedParameters) { - var refactorName = "Convert to named parameters"; + var convertParamsToDestructuredObject; + (function (convertParamsToDestructuredObject) { + var refactorName = "Convert parameters to destructured object"; var minimumParameterLength = 2; refactor.registerRefactor(refactorName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { @@ -119529,7 +119547,7 @@ var ts; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker()); if (!functionDeclaration) return ts.emptyArray; - var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_to_named_parameters); + var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object); return [{ name: refactorName, description: description, @@ -119912,7 +119930,7 @@ var ts; return ts.Debug.assertNever(functionDeclaration); } } - })(convertToNamedParameters = refactor.convertToNamedParameters || (refactor.convertToNamedParameters = {})); + })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); var ts; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index a19390015d0..7d963029b4d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -1434,6 +1434,9 @@ var ts; /** Do nothing and return true */ function returnTrue() { return true; } ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { return undefined; } + ts.returnUndefined = returnUndefined; /** Returns its argument. */ function identity(x) { return x; } ts.identity = identity; @@ -6377,7 +6380,7 @@ var ts; Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"), Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), - Convert_to_named_parameters: diag(95075, ts.DiagnosticCategory.Message, "Convert_to_named_parameters_95075", "Convert to named parameters"), + Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), }; })(ts || (ts = {})); var ts; @@ -11531,23 +11534,27 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + var getResolvedProjectReferenceToRedirect = function (fileName) { return host.getResolvedProjectReferenceToRedirect(fileName); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(host.getSourceFiles(), function (sourceFile) { - return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } else { var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) { + return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && + !sourceFile.isDeclarationFile && + !isSourceFileFromExternalLibrary(sourceFile) && + !(isJsonSourceFile(sourceFile) && getResolvedProjectReferenceToRedirect(sourceFile.fileName)); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -46837,6 +46844,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + ts.isSourceFile(symbol.valueDeclaration) || symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } @@ -55848,7 +55856,7 @@ var ts; // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); } } else { @@ -58268,7 +58276,7 @@ var ts; return undefined; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */) { + if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -63372,7 +63380,7 @@ var ts; ts.nullTransformationContext = { enableEmitNotification: ts.noop, enableSubstitution: ts.noop, - endLexicalEnvironment: function () { return undefined; }, + endLexicalEnvironment: ts.returnUndefined, getCompilerOptions: ts.notImplemented, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, @@ -82960,19 +82968,20 @@ var ts; function rootDirOfOptions(configFile) { return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); } + function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { + return outputDir ? + ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) : + inputFileName; + } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.declarationDir || configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); - return ts.changeExtension(outputPath, ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { - var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase); - var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)), relativePath); var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(outputPath, isJsonFile ? + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : @@ -83032,6 +83041,9 @@ var ts; if (jsFilePath) return jsFilePath; } + var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + if (buildInfoPath) + return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; @@ -83422,11 +83434,12 @@ var ts; getCompilerOptions: function () { return config.options; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNewLine: function () { return host.getNewLine(); }, - getSourceFile: function () { return undefined; }, - getSourceFileByPath: function () { return undefined; }, + getSourceFile: ts.returnUndefined, + getSourceFileByPath: ts.returnUndefined, getSourceFiles: function () { return sourceFilesForJsEmit; }, getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, + getResolvedProjectReferenceToRedirect: ts.returnUndefined, writeFile: function (name, text, writeByteOrderMark) { switch (name) { case jsFilePath: @@ -83467,7 +83480,7 @@ var ts; fileExists: function (f) { return host.fileExists(f); }, directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, - getProgramBuildInfo: function () { return undefined; } + getProgramBuildInfo: ts.returnUndefined }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); return outputFiles; @@ -88477,7 +88490,7 @@ var ts; } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -88866,7 +88879,8 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -89987,14 +90001,17 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); - if (rootNames.length < sourceFiles.length) { - var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); - for (var _i = 0, _a = sourceFiles.map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); _i < _a.length; _i++) { - var file = _a[_i]; - if (normalizedRootNames.indexOf(file) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); - } + var rootPaths = rootNames.map(toPath); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var file = files_3[_i]; + // Ignore declaration files + if (file.isDeclarationFile) + continue; + // Ignore json file thats from project reference + if (ts.isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) + continue; + if (rootPaths.indexOf(file.path) === -1) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName)); } } } @@ -90352,7 +90369,7 @@ var ts; readFile: function (f) { return directoryStructureHost.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (function () { return undefined; }), + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined, trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } @@ -91618,7 +91635,7 @@ var ts; backupState: ts.noop, restoreState: ts.noop, getProgram: ts.notImplemented, - getProgramOrUndefined: function () { return undefined; }, + getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, getCompilerOptions: function () { return state.compilerOptions; }, getSourceFile: ts.notImplemented, @@ -93591,7 +93608,7 @@ var ts; ts.createBuilderStatusReporter = createBuilderStatusReporter; function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) { var host = ts.createProgramHost(system, createProgram); - host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; + host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined; host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop; host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop; host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system); @@ -93843,13 +93860,14 @@ var ts; newestInputFileTime = inputTime; } } - // Collect the expected outputs of this project - var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); - if (outputs.length === 0) { + // Container if no files are specified in the project + if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) { return { type: UpToDateStatusType.ContainerOnly }; } + // Collect the expected outputs of this project + var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); // Now see if all outputs are newer than the newest input var oldestOutputFileName = "(none)"; var oldestOutputFileTime = maximumDate;