diff --git a/lib/tsc.js b/lib/tsc.js index af981c48612..ce174b7b087 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.7"; - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { function tryGetNativeMap() { @@ -8565,6 +8565,10 @@ var ts; return !!node && !!(node.flags & 33554432); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304); } @@ -71440,8 +71444,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -72961,11 +72968,12 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonFile = ts.isJsonSourceFile(sourceFile); + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -73000,7 +73008,7 @@ var ts; inputFileName; } function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts")); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json")); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts"); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -73217,9 +73225,10 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false); if (ts.length(declarationTransform.diagnostics)) { @@ -78007,7 +78016,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts")) { + if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined); } } @@ -79186,7 +79195,7 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts")) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) { return undefined; } return getResolvedProjectReferenceToRedirect(fileName); @@ -79233,7 +79242,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts")) { + if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -81740,7 +81749,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { @@ -81782,13 +81791,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; } diff --git a/lib/tsserver.js b/lib/tsserver.js index e04799259f1..0a728d45f6a 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -11324,6 +11324,10 @@ var ts; return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304 /* JSDoc */); } @@ -87719,8 +87723,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; // No declaration diagnostics for json for now + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -89467,12 +89474,13 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -89513,7 +89521,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -89742,12 +89750,13 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -95003,7 +95012,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -96383,8 +96392,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + // Ignore dts or any json files + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -96438,7 +96447,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -99398,7 +99407,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** @@ -99445,13 +99454,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 0dd89df1abf..f6339dec454 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -11474,6 +11474,10 @@ var ts; return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304 /* JSDoc */); } @@ -87869,8 +87873,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; // No declaration diagnostics for json for now + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -89617,12 +89624,13 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -89663,7 +89671,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -89892,12 +89900,13 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -95153,7 +95162,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -96533,8 +96542,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + // Ignore dts or any json files + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -96588,7 +96597,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -99548,7 +99557,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** @@ -99595,13 +99604,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; } diff --git a/lib/typescript.js b/lib/typescript.js index 509da4c8665..f02a2dc063d 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -233,7 +233,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -11463,6 +11463,10 @@ var ts; return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304 /* JSDoc */); } @@ -87858,8 +87862,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; // No declaration diagnostics for json for now + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -89606,12 +89613,13 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -89652,7 +89660,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -89881,12 +89889,13 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -95142,7 +95151,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -96522,8 +96531,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + // Ignore dts or any json files + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -96577,7 +96586,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -99537,7 +99546,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** @@ -99584,13 +99593,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 1270810d10e..5c74888c35a 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -233,7 +233,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -11463,6 +11463,10 @@ var ts; return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304 /* JSDoc */); } @@ -87858,8 +87862,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; // No declaration diagnostics for json for now + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -89606,12 +89613,13 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -89652,7 +89660,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -89881,12 +89889,13 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -95142,7 +95151,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -96522,8 +96531,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + // Ignore dts or any json files + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -96577,7 +96586,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -99537,7 +99546,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** @@ -99584,13 +99593,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index e6e0c96b8e3..c6babb0b40d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -11313,6 +11313,10 @@ var ts; return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; + function isSourceFileNotJson(file) { + return !isJsonSourceFile(file); + } + ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { return !!node && !!(node.flags & 4194304 /* JSDoc */); } @@ -87708,8 +87712,11 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { + if (file && ts.isJsonSourceFile(file)) { + return []; // No declaration diagnostics for json for now + } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -89456,12 +89463,13 @@ var ts; } else { var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it - var isJsonEmittedToSameLocation = ts.isJsonSourceFile(sourceFile) && + var isJsonEmittedToSameLocation = isJsonFile && ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -89502,7 +89510,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -89731,12 +89739,13 @@ var ts; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; + var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - sourceFiles.forEach(collectLinkedAliases); + filesForEmit.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -94992,7 +95001,7 @@ var ts; else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { var fileName = _d[_c]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -96372,8 +96381,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + // Ignore dts or any json files + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -96427,7 +96436,7 @@ var ts; } else { ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -99387,7 +99396,7 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectrorySeparators(a, b) { + function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** @@ -99434,13 +99443,28 @@ var ts; }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } + var newDirectory = ts.getDirectoryPath(directory); + if (newDirectory === directory) + return out_directory_1 = directory, "break"; + directory = newDirectory; + out_directory_1 = directory; }; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { - _loop_17(directory); + var out_directory_1; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { + var state_7 = _loop_17(directory); + directory = out_directory_1; + if (state_7 === "break") + break; + } + if (allFileNames.size) { + var remainingPaths = ts.arrayFrom(allFileNames.values()); + if (remainingPaths.length > 1) + remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; }