From e2868216f637e875a74c675845625eb15dcfe9a2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 6 Dec 2022 17:42:25 +0000 Subject: [PATCH] Bump version to 4.9.4 and LKG. --- lib/tsc.js | 42 +++++++++++++++++++++-------------- lib/tsserver.js | 45 ++++++++++++++++++++++++-------------- lib/tsserverlibrary.js | 45 ++++++++++++++++++++++++-------------- lib/typescript.js | 45 ++++++++++++++++++++++++-------------- lib/typescriptServices.js | 45 ++++++++++++++++++++++++-------------- lib/typingsInstaller.js | 45 ++++++++++++++++++++++++-------------- package.json | 2 +- src/compiler/corePublic.ts | 2 +- 8 files changed, 167 insertions(+), 104 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 0ac0683ff06f2..80afaea533e28 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.9"; - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); var NativeCollections; (function (NativeCollections) { var globals = typeof globalThis !== "undefined" ? globalThis : @@ -57536,7 +57536,8 @@ var ts; return !!(type.flags & 109440); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + var t = getBaseConstraintOrType(type); + return t.flags & 2097152 ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 ? ts.find(type.types, isUnitType) || type : type; @@ -66236,11 +66237,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -77596,8 +77597,8 @@ var ts; _a[302] = function visitEachChildOfEnumMember(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, - _a[308] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, undefined, undefined, nodesVisitor)); + _a[308] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, _a[353] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); @@ -104718,12 +104719,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -104754,6 +104756,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -104769,9 +104772,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -104887,7 +104890,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -104972,7 +104975,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { var args = []; @@ -105092,8 +105095,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -105218,9 +105221,14 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -105652,7 +105660,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -106634,7 +106642,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/tsserver.js b/lib/tsserver.js index 4d7f350bb9174..a2960e9f6795b 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -109,7 +109,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68904,7 +68904,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79084,11 +79087,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91973,8 +91976,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126211,12 +126214,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126247,6 +126251,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126265,9 +126270,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126399,7 +126404,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126485,7 +126490,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126613,8 +126618,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126753,9 +126758,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127249,7 +127260,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128282,7 +128293,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 4c9c38508f58d..1b41c9347d2f7 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -108,7 +108,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68903,7 +68903,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79083,11 +79086,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91972,8 +91975,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126210,12 +126213,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126246,6 +126250,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126264,9 +126269,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126398,7 +126403,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126484,7 +126489,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126612,8 +126617,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126752,9 +126757,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127248,7 +127259,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128281,7 +128292,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typescript.js b/lib/typescript.js index 7e5216130ba64..c2688dd27c335 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -99,7 +99,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68894,7 +68894,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79074,11 +79077,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91963,8 +91966,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126201,12 +126204,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126237,6 +126241,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126255,9 +126260,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126389,7 +126394,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126475,7 +126480,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126603,8 +126608,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126743,9 +126748,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127239,7 +127250,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128272,7 +128283,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 27225845567c3..98086d72a80af 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -99,7 +99,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68894,7 +68894,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79074,11 +79077,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91963,8 +91966,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126201,12 +126204,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126237,6 +126241,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126255,9 +126260,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126389,7 +126394,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126475,7 +126480,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126603,8 +126608,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126743,9 +126748,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127239,7 +127250,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128272,7 +128283,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index df6dbf82ce8c7..a4a6c6314ce7e 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -89,7 +89,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68884,7 +68884,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79064,11 +79067,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91953,8 +91956,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126191,12 +126194,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126227,6 +126231,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126245,9 +126250,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126379,7 +126384,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126465,7 +126470,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126593,8 +126598,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126733,9 +126738,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127229,7 +127240,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128262,7 +128273,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/package.json b/package.json index 18f05a1d55942..f5de7c1fc823a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.9.3", + "version": "4.9.4", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 778475b396366..449bd11b603ff 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version: string = `${versionMajorMinor}.3`; + export const version: string = `${versionMajorMinor}.4`; /** * Type of objects whose values are all of the same type.