Skip to content

Commit

Permalink
Update LKG.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Jan 15, 2020
1 parent c81b9a7 commit 9d42982
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 91 deletions.
52 changes: 38 additions & 14 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
56 changes: 40 additions & 16 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
}
/**
Expand Down Expand Up @@ -99445,13 +99454,28 @@ var ts;
});
if (pathsInDirectory) {
if (pathsInDirectory.length > 1) {
pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators);
pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators);
}
sortedPaths.push.apply(sortedPaths, pathsInDirectory);
}
};
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) {
_loop_17(directory);
var newDirectory = ts.getDirectoryPath(directory);
if (newDirectory === directory)
return out_directory_1 = directory, "break";
directory = newDirectory;
out_directory_1 = 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;
}
Expand Down
Loading

0 comments on commit 9d42982

Please sign in to comment.